Created
November 20, 2013 16:09
-
-
Save halgatewood/7565804 to your computer and use it in GitHub Desktop.
Expire all membership levels at the end of the year. If the user registers after October (10 variable on line 8) then they'll expire in the next year.
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
/// EXPIRATION DATE | |
function my_pmpro_checkout_level($level) | |
{ | |
$expiration_year = date('Y'); | |
$current_month = date('n'); | |
// IF OCT, NOV, DEC, EXPIRE NEXT YEAR | |
if($current_month >= 10) { $expiration_year++; } | |
$expiration_date = $expiration_year . "-12-31"; | |
//needed below | |
$todays_date = time(); | |
//how many days until expiration? | |
$time_left = strtotime($expiration_date) - $todays_date; | |
$days_left = ceil( $time_left / (60*60*24) ); | |
//update number and period | |
$level->expiration_number = $days_left; | |
$level->expiration_period = "Day"; | |
return $level; | |
} | |
add_filter("pmpro_checkout_level", "my_pmpro_checkout_level"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment