Created
September 15, 2026 11:28
-
-
Save dwanjuki/0c0a6ab06f1d127e3339ca4f58195802 to your computer and use it in GitHub Desktop.
Cancel membership level and subscription at payment gateway when a member is denied.
This file contains hidden or 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 membership level and subscription at payment gateway when a member is denied. | |
| * | |
| * You can add this recipe to your site by creating a custom plugin | |
| * or using the Code Snippets plugin available for free in the WordPress repository. | |
| * Read this companion article for step-by-step directions on either method. | |
| * https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
| */ | |
| function my_pmpro_cancel_membership_on_denial( $user_id, $level_id ) { | |
| // Cancel the membership level, which also cancels any associated subscription at the gateway. | |
| pmpro_cancelMembershipLevel( $level_id, $user_id, 'admin_cancelled' ); | |
| } | |
| add_action( 'pmpro_approvals_after_deny_member', 'my_pmpro_cancel_membership_on_denial', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment