-
-
Save michaelbeil/d00c5bdea686d599c0d214f6e95f4279 to your computer and use it in GitHub Desktop.
Move PMPro members to another level when they cancel.
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 | |
/** | |
* By default cancelled members are changed to level 0. This recipe changes that behavior to give them a "cancelled" level that | |
* you have created for that purpose. Can be used to downgrade someone to a free level if they cancel. | |
*/ | |
/** | |
* [pmpro_after_change_membership_level_default_level description] | |
* | |
* @param [type] $level_id [description] | |
* @param [type] $user_id [description] | |
* @return [type] [description] | |
*/ | |
function pmpro_after_change_membership_level_default_level( $level_id, $user_id ) { | |
// if we see this global set, then another gist is planning to give the user their level back | |
global $pmpro_next_payment_timestamp; | |
if ( ! empty( $pmpro_next_payment_timestamp ) ) { | |
return; | |
} | |
if ( $level_id == 0 ) { | |
// cancelling, give them level 1 instead | |
pmpro_changeMembershipLevel( 1, $user_id ); | |
} | |
} | |
add_action( 'pmpro_after_change_membership_level', 'pmpro_after_change_membership_level_default_level', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment