Forked from andrewlimaza/pmpro_level_expiring_soon_example.php
Created
February 2, 2019 23:55
-
-
Save itsjusteileen/10eff96d8107253a13bfa373c980d1e4 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