Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stop different members on different levels from renewing their current membership level [Paid Memberships Pro].
<?php // Do not copy this line
/**
* Stop members from renewing their current membership level.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function stop_members_from_renewing( $okay ) {
// If something else isn't okay, stop from running this code further.
if ( ! $okay ) {
return $okay;
}
// If the user doesn't have a membership level carry on with checkout.
if ( ! pmpro_hasMembershipLevel() ) {
return $okay;
}
// Check if the user's current membership level is the same for checking out.
if ( pmpro_hasMembershipLevel( '1' ) && $_REQUEST['level'] == '1' ) { // Change level ID to a different level.
$okay = false;
pmpro_setMessage( 'Your message here. And a thanks perhaps!', 'pmpro_error' );
}
if ( pmpro_hasMembershipLevel( '2' ) && $_REQUEST['level'] == '2' ) {
$okay = false;
pmpro_setMessage( 'Your message here. And a thanks perhaps!', 'pmpro_error' );
}
if ( pmpro_hasMembershipLevel( '3' ) && $_REQUEST['level'] == '3' ) {
$okay = false;
pmpro_setMessage( 'Your message here. And a thanks perhaps!', 'pmpro_error' );
}
if ( pmpro_hasMembershipLevel( '4' ) && $_REQUEST['level'] == '4' ) {
$okay = false;
pmpro_setMessage( 'Your message here. And a thanks perhaps!', 'pmpro_error' );
}
if ( pmpro_hasMembershipLevel( '5' ) && $_REQUEST['level'] == '5' ) {
$okay = false;
pmpro_setMessage( 'Your current membership level (Reduced eIJO) is being phased out as we simplify our membership structure. Please select the updated Reduced membership category to renew your WDA membership. Thank you!', 'pmpro_error' );
}
if ( pmpro_hasMembershipLevel( '8' ) && $_REQUEST['level'] == '8' ) {
$okay = false;
pmpro_setMessage( 'Your message here. And a thanks perhaps!', 'pmpro_error' );
}
if ( pmpro_hasMembershipLevel( '9' ) && $_REQUEST['level'] == '9' ) {
$okay = false;
pmpro_setMessage( 'Your message here. And a thanks perhaps!', 'pmpro_error' );
}
return $okay;
}
add_filter( 'pmpro_registration_checks', 'stop_members_from_renewing', 10, 1 );
@adcadesigns
Copy link

adcadesigns commented Jun 10, 2021

Hi, can you please recheck the code its not working anymore. thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment