Skip to content

Instantly share code, notes, and snippets.

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 travislima/acfec23184912b3ffc1a77fa5474b102 to your computer and use it in GitHub Desktop.
Save travislima/acfec23184912b3ffc1a77fa5474b102 to your computer and use it in GitHub Desktop.
Stop members from renewing their current membership level [Paid Memberships Pro].
<?php
/**
* 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( '2' ) && $_REQUEST['level'] == '2' ) { // Change level ID to a different level.
$okay = false;
pmpro_setMessage( 'This is your current membership level. Please select a different membership level.', 'pmpro_error' );
}
return $okay;
}
add_filter( 'pmpro_registration_checks', 'stop_members_from_renewing', 10, 1 );
@MaryOJob
Copy link

To stop different members on different levels from renewing their current membership level [Paid Memberships Pro].

Please see: https://gist.github.com/MaryOJob/711f9216802a7b91a3833f046347b436

@laurenhagan0306
Copy link

This recipe is included in the blog post on "How to stop members from renewing their membership level." at Paid Memberships Pro here:https://www.paidmembershipspro.com/how-to-stop-members-from-renewing-their-membership-level/

@adcadesigns
Copy link

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

@gnpwdr-mike
Copy link

Agreeing with @adcadesigns. This does not appear to be valid anymore. /cc @laurenhagan0306 @travislima

@andrewlimaza
Copy link

I've tested this and it still works. Please adjust line 20 for the level ID's that you would like to restrict.

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