Skip to content

Instantly share code, notes, and snippets.

@scottsousa
Created January 23, 2014 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottsousa/8580472 to your computer and use it in GitHub Desktop.
Save scottsousa/8580472 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Prevent users from downgrading levels.
/**
* Prevent users from downgrading levels.
*/
add_filter( 'pmpro_checkout_level', 'my_pmpro_checkout_level' );
function my_pmpro_checkout_level( $level ) {
// Check to see if the current user is downgrading (Gold to Silver or Gold to Free)
if( pmpro_hasMembershipLevel( 3 ) && ( $level->id == 2 || $level->id == 1 ) ) {
// Re-direct them to page explaining why they cannot downgrade
wp_redirect( home_url( '/gold-downgrade-message' ) );
exit;
}
// Check to see if the current user is downgrading (Silver to Free)
else if( pmpro_hasMembershipLevel( 2 ) && $level->id == 1 ) {
// Re-direct them to page explaining why they cannot downgrade
wp_redirect( home_url( '/silver-downgrade-message' ) );
exit;
}
return $level;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment