Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Last active May 12, 2021 22:05
Show Gist options
  • Save strangerstudios/5703500 to your computer and use it in GitHub Desktop.
Save strangerstudios/5703500 to your computer and use it in GitHub Desktop.
Place a PMPro member in another level when they cancel.
/*
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