Forked from strangerstudios/my_pmpro_registration_checks.php
Last active
December 28, 2020 12:51
-
-
Save JarrydLong/24d04c7de0e6f4f9ddd2f2dbff617af6 to your computer and use it in GitHub Desktop.
Require a certain level before registering for another level with 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 | |
/* | |
Require a certain level before registering for another level. | |
Add this code to your active theme's functions.php or | |
a custom plugin. | |
*/ | |
function my_pmpro_registration_checks($okay){ | |
//only check if things are okay so far | |
if($okay) | |
{ | |
global $pmpro_level; | |
if( | |
( $pmpro_level->id == 2 && !pmpro_hasMembershipLevel( 1 ) ) || | |
( $pmpro_level->id == 4 && !pmpro_hasMembershipLevel( 3 ) ) | |
){ | |
pmpro_setMessage("You must be a free member first before registering for this level.", "pmpro_error"); | |
$okay = false; | |
} | |
} | |
return $okay; | |
} | |
add_action("pmpro_registration_checks", "my_pmpro_registration_checks"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment