Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ideadude/f57100a6e7398e4db097b84957914582 to your computer and use it in GitHub Desktop.
Save ideadude/f57100a6e7398e4db097b84957914582 to your computer and use it in GitHub Desktop.
Cancel PMPro subscriptions when a recurring payment fails.
<?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