Forked from strangerstudios/pmpro_cancelled_level.php
Last active
March 8, 2016 18:33
-
-
Save greathmaster/51ebce0093d5f892a762 to your computer and use it in GitHub Desktop.
Place a PMPro member in another level and give them a new expiration date when they cancel.
This file contains 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
/* | |
When users cancel (are changed to membership level 0) we give them another "cancelled" level. Can be used to downgrade someone to a free level when they cancel. | |
*/ | |
function my_pmpro_after_change_membership_level($level_id, $user_id) | |
{ | |
if($level_id == 0) | |
{ | |
//cancelling, give them level 1 instead | |
$expiry_level_id = 1; | |
$level = pmpro_getLevel($expiry_level_id); | |
//give them an expiry date one year from today. | |
$level->enddate = date('Y-m-d',strtotime(date("Y-m-d", mktime()) . " + 365 day")); | |
pmpro_changeMembershipLevel($level, $user_id); | |
} | |
} | |
add_action("pmpro_after_change_membership_level", "my_pmpro_after_change_membership_level", 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment