Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaryOJob/f7545365cc64d2700962ad71eba48e76 to your computer and use it in GitHub Desktop.
Save MaryOJob/f7545365cc64d2700962ad71eba48e76 to your computer and use it in GitHub Desktop.
Change membership level when a user expires only - Paid Memberships Pro
<?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