Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsjusteileen/1c6ec39cdafcdfdda47121c3907606e4 to your computer and use it in GitHub Desktop.
Save itsjusteileen/1c6ec39cdafcdfdda47121c3907606e4 to your computer and use it in GitHub Desktop.
Setup Level 3 to start next Monday and end the following Monday with Paid Memberships Pro.
/*
Setup Level 3 to start next Monday and end the following Monday
Requires PMPro 1.8.9 or higher.
Add this code to your active theme's functions.php or a custom plugin.
*/
//startdate
function my_pmpro_checkout_start_date($enddate, $user_id, $level) {
if($level->id == 3)
$startdate = "'" . date('Y-m-d', strtotime('next Monday', current_time('timestamp'))) . "'";
return $startdate;
}
add_action('pmpro_checkout_start_date', 'my_pmpro_checkout_start_date', 10, 3);
//enddate
function my_pmpro_checkout_end_date($enddate, $user_id, $level, $startdate) {
if($level->id == 3 && $level->expiration_number > 0)
$enddate = "'" . date("Y-m-d", strtotime("+ " . $level->expiration_number . " " . $level->expiration_period, strtotime(trim($startdate,"'")) )) . "'";
return $enddate;
}
add_action('pmpro_checkout_end_date', 'my_pmpro_checkout_end_date', 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment