Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ipokkel/4a6de7b1d3ee739c114f0b2b8b4eee1e to your computer and use it in GitHub Desktop.
Save ipokkel/4a6de7b1d3ee739c114f0b2b8b4eee1e to your computer and use it in GitHub Desktop.
Reset visits, views and logins for Paid Memberships Pro.
<?php
/**
* Add &pmpro_reset_analytics=1 to your WordPress dashboard URL/Paid Memberships Pro reports page.
* Add this code to your Code Snippets / Custom Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* You may remove this code from your site when you don't need it any longer.
*/
function my_pmpro_reset_visit_data() {
// Check if URL parameter pmpro_reset_analytics is set
if ( isset( $_REQUEST['pmpro_reset_analytics'] ) ) {
// Clear visits, views and logins
delete_option( 'pmpro_visits' );
delete_option( 'pmpro_views' );
delete_option( 'pmpro_logins' );
// clear reports
delete_option( '_transient_timeout_pmpro_report_prices_paid' );
delete_option( '_transient_pmpro_report_prices_paid ' );
delete_option( '_transient_timeout_pmpro_report_sales' );
delete_option( '_transient_pmpro_report_sales' );
delete_option( '_transient_timeout_pmpro_report_revenue' );
delete_option( '_transient_pmpro_report_revenue' );
delete_option( '_transient_timeout_pmpro_report_memberships_signups' );
delete_option( '_transient_pmpro_report_memberships_signups' );
delete_option( '_transient_timeout_pmpro_report_memberships_cancellations' );
delete_option( '_transient_pmpro_report_memberships_cancellations' );
}
}
add_action( 'init', 'my_pmpro_reset_visit_data' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment