Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save femiyb/3d6c17f4ce0b5dba765c32bf5fd45f74 to your computer and use it in GitHub Desktop.

Select an option

Save femiyb/3d6c17f4ce0b5dba765c32bf5fd45f74 to your computer and use it in GitHub Desktop.
Change membership level when a user expires
<?php
/**
* 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( 1, $user_id ); // Change this to default level.
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