Forked from andrewlimaza/pmpro_level_expiring_soon_example.php
Last active
October 8, 2025 10:12
-
-
Save JarrydLong/5802520c54c9b0567244678f467e2b45 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. | |
| * Only do this for levels that are not recurring. | |
| * 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 ) { | |
| if( $level->billing_amount > 0 ) { | |
| return $r; //dont change for recurring levels | |
| } | |
| $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