Forked from strangerstudios/pmpro-cancel-on-billing-failure.php
Last active
February 2, 2021 11:20
-
-
Save ideadude/f57100a6e7398e4db097b84957914582 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
<?php | |
/** | |
* Cancel subscriptions when a recurring payment fails. | |
* You should also use the PMPro Email Templates Add On to edit the | |
* default billing_failure.html email to mention that users are cancelled upon failure. | |
*/ | |
function my_cancel_subscriptions_on_any_failed_payment( $order ) { | |
pmpro_cancelMembershipLevel( $order->membership_id, $order->user_id ); | |
} | |
add_action( 'pmpro_subscription_payment_failed', 'my_cancel_subscriptions_on_any_failed_payment' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment