Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save strangerstudios/5093710 to your computer and use it in GitHub Desktop.
Save strangerstudios/5093710 to your computer and use it in GitHub Desktop.
Cancel PMPro membership when the subscription is deleted at Stripe
/*
Cancel subscriptions when the subscription is deleted at Stripe
Requires PMPro 1.6 or higher.
*/
function my_pmpro_stripe_subscription_deleted($user_id)
{
//cancel the membership
pmpro_changeMembershipLevel(0, $user_id);
}
add_action("pmpro_stripe_subscription_deleted", "my_pmpro_stripe_subscription_deleted");
@italianfresh
Copy link

italianfresh commented Dec 7, 2021

Hi, I know this thread is from a long time ago but I have a similar problem.

I want to do the same as the partner but when trying to collect the $user_id it says that the variable is not defined.

I have tried with $user_id, $user->ID and with get_current_user_id()

It is not capable of knowing the user id and therefore it is not able to assign the level I want.

If anyone knows or can help me.

Thanks!

My code:

add_action("pmpro_stripe_subscription_deleted",` "asign_elemental_level_when_cancel_in_stripe");

function asign_elemental_level_when_cancel_in_stripe($user_id) {
pmpro_changeMembershipLevel(3, $user_id);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment