Created
March 2, 2022 15:26
-
-
Save sc0ttkclark/da89b4165406b37d7d309648a9c48f41 to your computer and use it in GitHub Desktop.
Reset the Cron Schedules for Paid Memberships Pro. The single-use version can be found at: https://gist.github.com/sc0ttkclark/bd319a47656b786ccee3eca6f2dc4a9a and the PMPro admin page only version can be found at: https://gist.github.com/sc0ttkclark/e11691d6c5a278662e3c694a0bb12e5a
This file contains 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 | |
/** | |
* Reset the Cron Schedules for Paid Memberships Pro on any page load. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
/** | |
* Handle resetting the cron schedules for PMPro on init. | |
*/ | |
function my_pmpro_reset_cron_schedules_on_init() { | |
// Only run if on a PMPro admin page. | |
if ( empty( $_GET['page'] ) || 0 !== strpos( $_GET['page'], 'pmpro-' ) ) { | |
return; | |
} | |
pmpro_maybe_schedule_event( current_time( 'timestamp' ), 'hourly', 'pmpro_cron_expire_memberships' ); | |
pmpro_maybe_schedule_event( current_time( 'timestamp' ) + 1, 'hourly', 'pmpro_cron_expiration_warnings' ); | |
pmpro_maybe_schedule_event( current_time( 'timestamp' ), 'monthly', 'pmpro_cron_credit_card_expiring_warnings' ); | |
pmpro_maybe_schedule_event( strtotime( '10:30:00' ) - ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ), 'daily', 'pmpro_cron_admin_activity_email' ); | |
} | |
add_action( 'init', 'my_pmpro_reset_cron_schedules_on_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment