Created
January 23, 2014 15:26
-
-
Save scottsousa/8580472 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Prevent users from downgrading levels.
This file contains 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
/** | |
* 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