Last active
May 12, 2021 22:05
-
-
Save strangerstudios/5703500 to your computer and use it in GitHub Desktop.
Place a PMPro member in another level 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 pmpro_after_change_membership_level_default_level($level_id, $user_id) | |
{ | |
//if we see this global set, then another gist is planning to give the user their level back | |
global $pmpro_next_payment_timestamp; | |
if(!empty($pmpro_next_payment_timestamp)) | |
return; | |
if($level_id == 0) { | |
//cancelling, give them level 1 instead | |
pmpro_changeMembershipLevel(1, $user_id); | |
} | |
} | |
add_action("pmpro_after_change_membership_level", "pmpro_after_change_membership_level_default_level", 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment