Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JarrydLong/24d04c7de0e6f4f9ddd2f2dbff617af6 to your computer and use it in GitHub Desktop.
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.
<?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