Last active
August 31, 2020 17:21
-
-
Save strangerstudios/3678054 to your computer and use it in GitHub Desktop.
Revisions
-
ideadude revised this gist
Dec 31, 2012 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ /* Important note! This code is included in PMPro versions 1.5.7 and later. Adding this code will add 2x the number of days to the end of the subscription. */ //if checking out for the same level, add remaining days to the enddate function my_pmpro_checkout_level($level) { -
ideadude created this gist
Sep 8, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ //if checking out for the same level, add remaining days to the enddate function my_pmpro_checkout_level($level) { global $pmpro_msg, $pmpro_msgt; //does this level expire? are they an existing user of this level? if($level->expiration_number && pmpro_hasMembershipLevel($level->id)) { //get the current enddate of their membership global $current_user; $expiration_date = $current_user->membership_level->enddate; //calculate days left $todays_date = time(); $time_left = $expiration_date - $todays_date; //time left? if($time_left > 0) { //convert to days and add to the expiration date (assumes expiration was 1 year) $days_left = floor($time_left/(60*60*24)); //figure out days based on period if($level->expiration_period == "Day") $total_days = $days_left + $level->expiration_number; elseif($level->expiration_period == "Week") $total_days = $days_left + $level->expiration_number * 7; elseif($level->expiration_period == "Month") $total_days = $days_left + $level->expiration_number * 30; elseif($level->expiration_period == "Year") $total_days = $days_left + $level->expiration_number * 365; //update number and period $level->expiration_number = $total_days; $level->expiration_period = "Day"; } } return $level; } add_filter("pmpro_checkout_level", "my_pmpro_checkout_level");