Skip to content

Instantly share code, notes, and snippets.

@femiyb
Last active September 30, 2019 10:53
Show Gist options
  • Save femiyb/b63f5c78806aa2e4de90ea06cd182b43 to your computer and use it in GitHub Desktop.
Save femiyb/b63f5c78806aa2e4de90ea06cd182b43 to your computer and use it in GitHub Desktop.
Disable Registration based on Register Helper field value
<?php
/*
Disable Registration based on Register Helper field value
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(isset($_REQUEST['not_permitted']) && $_REQUEST['not_permitted'] == 'yes')
{
pmpro_setMessage("You are not permitted to register 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