Skip to content

Instantly share code, notes, and snippets.

@halgatewood
Created November 20, 2013 16:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halgatewood/7565804 to your computer and use it in GitHub Desktop.
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.
/// 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