Skip to content

Instantly share code, notes, and snippets.

@dparker1005
Created June 14, 2019 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dparker1005/db9f53119e278d2a78bcd25a34fc906a to your computer and use it in GitHub Desktop.
Save dparker1005/db9f53119e278d2a78bcd25a34fc906a to your computer and use it in GitHub Desktop.
When a user's level is changed to not have a membership, instead give them the free level
<?php
function my_pmpro_after_change_membership_level( $level_id, $user_id ) {
// TODO: Replace '1' with level id of free level
$free_level = 1;
if ( $level_id == 0 && empty( $_REQUEST['delete_account'] ) ) {
//cancelling, give them level 1 instead
pmpro_changeMembershipLevel( $free_level, $user_id );
}
}
add_action("pmpro_after_change_membership_level", "my_pmpro_after_change_membership_level", 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment