Forked from MaryOJob/stop-renewing-members-multiple-levels.php
Created
March 4, 2022 13:25
-
-
Save kimwhite/091db594d8406c340145d24ad3c920bd to your computer and use it in GitHub Desktop.
Stop different members on different levels from renewing their current membership level [Paid Memberships Pro].
This file contains hidden or 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
<?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/ | |
*/ | |
/** | |
* 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( 'Your already own this level!', 'pmpro_error' ); | |
} | |
return $okay; | |
} | |
add_filter( 'pmpro_registration_checks', 'stop_members_from_renewing', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment