Forked from andrewlimaza/only-set-default-membership-level-on-expiration.php
Last active
May 26, 2021 15:01
-
-
Save MaryOJob/f7545365cc64d2700962ad71eba48e76 to your computer and use it in GitHub Desktop.
Change membership level when a user expires only - Paid Memberships Pro
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 // Do not copy this line | |
/** | |
* Set a default membership level when a user expires (only). | |
* This does not set the default level when a user cancels. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function pmpro_set_default_level_only_when_expiring( $user_id, $level_id ) { | |
pmpro_changeMembershipLevel( 2, $user_id ); // replace 2 with the id of the membership level you want users switched to. | |
return $user_id; | |
} | |
add_filter( 'pmpro_membership_post_membership_expiry', 'pmpro_set_default_level_only_when_expiring', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment