Created
May 26, 2025 10:46
-
-
Save dwanjuki/b932fa92fe15f6b16f1dba3e9f24dd7b to your computer and use it in GitHub Desktop.
Add cancelled level's ID to Changed Membership Level trigger data if a membership is being cancelled
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 | |
/** | |
* Add cancelled level's ID to Changed Membership Level trigger data | |
* if a membership is being cancelled | |
* | |
* 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_pmproz_after_change_membership_level_data( $data, $level_id, $user_id, $cancel_level ) { | |
if ( ! empty( $cancel_level) ) { | |
$data['cancelled_level_id'] = $cancel_level; | |
} | |
return $data; | |
} | |
add_filter( 'pmproz_after_change_membership_level_data', 'my_pmproz_after_change_membership_level_data', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment