Last active
December 3, 2020 14:30
-
-
Save strangerstudios/5044549 to your computer and use it in GitHub Desktop.
Cancel PMPro subscriptions when a recurring payment fails.
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
/* | |
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