Created
April 1, 2016 16:00
-
-
Save strangerstudios/d2e1144158f840fceaba5bbbad5f01fc 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.
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
/* | |
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