Last active
March 27, 2021 00:03
-
-
Save ronalfy/0e4324f8fa9e89d2bfb092623a253e4a to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Skip Tracking for Admins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Remove stats tracking for admins. | |
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_remove_admin_tracking_skip() { | |
if ( current_user_can( 'administrator' ) ) { | |
remove_action( 'wp_head', 'pmpro_report_login_wp_views' ); | |
} | |
} | |
add_action( 'init', 'pmpro_remove_admin_tracking_skip' ); | |
function pmpro_pre_login_check( $user_login, $user ) { | |
if ( $user->has_cap( 'administrator' ) ) { | |
remove_action( 'wp_login', 'pmpro_report_login_wp_login', 10, 2 ); | |
} | |
} | |
add_action( 'wp_login', 'pmpro_pre_login_check', 9, 2 ); | |
function pmpro_remove_visits_check() { | |
if ( current_user_can( 'administrator' ) ) { | |
remove_action( 'wp', 'pmpro_report_login_wp_visits' ); | |
} | |
} | |
add_action( 'wp', 'pmpro_remove_visits_check', 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Disable Visits, Views, and Logins Report Stats for a Specific User Role" at Paid Memberships Pro: https://www.paidmembershipspro.com/disable-visits-views-and-logins-report-stats-for-a-specific-user-role/