Last active
June 15, 2021 14:57
-
-
Save andrewlimaza/06ea68e604321e76dac22d69a445ac30 to your computer and use it in GitHub Desktop.
Change when user can renew their membership PMPro
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 | |
/** | |
* 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