Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active June 15, 2021 14:57
Show Gist options
  • Save andrewlimaza/06ea68e604321e76dac22d69a445ac30 to your computer and use it in GitHub Desktop.
Save andrewlimaza/06ea68e604321e76dac22d69a445ac30 to your computer and use it in GitHub Desktop.
Change when user can renew their membership PMPro
<?php
/**
* Allow members to only renew if their membership expires in 45 days or less.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function custom_pmpro_is_level_expiring_soon( $r, $level ) {
$days = 45; //change number of days before someone is allowed to renew.
$r = false;
$now = current_time('timestamp');
if( $now + ($days*3600*24) >= $level->enddate ) {
$r = true;
}
return $r;
}
add_filter( 'pmpro_is_level_expiring_soon', 'custom_pmpro_is_level_expiring_soon', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment