Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cancel PMPro subscriptions when a recurring payment fails.
/*
Cancel subscriptions when a recurring payment fails. As of PMPro version 1.5.9.1, failed payments reported via Stripe webhook, PayPal IPN handler, or Authorize.net silent post kick off the pmpro_subscription_payment_failed action.
Also make sure to edit the default billing_failure.html email to mention that users are cancelled upon failure. To do so, copy paid-memberships-pro/email/billing_failure.html into themes/{active theme}/paid-memberships-pro/email/ and edit the text to suit your need.
Note: This cancels on the first failure. To cancel only when cancelling at Stripe, see this gist: https://gist.github.com/strangerstudios/5093710
*/
function my_pmpro_subscription_payment_failed($order)
{
//cancel the membership
pmpro_changeMembershipLevel(0, $order->user_id);
}
add_action("pmpro_subscription_payment_failed", "my_pmpro_subscription_payment_failed");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.