Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/0ff027fe2dc1aeea780c09f89fd95f2b to your computer and use it in GitHub Desktop.
Save kimwhite/0ff027fe2dc1aeea780c09f89fd95f2b to your computer and use it in GitHub Desktop.
Reset visits, views logins and sales and Revenue for Paid Memberships Pro.
<?php
/**
* Add http://yoursite.com/wp-admin/admin.php?&pmpro_reset_analytics=1 to your url while logged in.
* 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