Hello. Good to hear your site is back up. Did you paste the entire code gist or just the one line above? If you only pasted the one line above try this…remove that one line and paste the following code into your theme’s functions.php file:
/*
Only let members for a certain level sign up if they use a discount code.
Place this code in your active theme's functions.php or a custom plugin.
*/
function my_pmpro_registration_checks_require_code_to_register($pmpro_continue_registration)
{
//only bother if things are okay so far
if(!$pmpro_continue_registration)
return $pmpro_continue_registration;
//level = 1 and there is no discount code, then show an error message
global $pmpro_level, $discount_code;
if($pmpro_level->id == YOUR_LEVEL_ID && (empty($discount_code) || $discount_code != "REQUIRED_CODE")) //use this conditional to check for a specific code.
//if($pmpro_level->id == 1 && empty($discount_code))
{
pmpro_setMessage("You must use a valid discount code to register for this level.", "pmpro_error");
return false;
}
return $pmpro_continue_registration;
}
add_filter("pmpro_registration_checks", "my_pmpro_registration_checks_require_code_to_register");
You should replace the YOUR_LEVEL_ID with the level ID you wish to restrict and replace the REQUIRED_CODE with the discount code you associated with the level. Let us know if this helps. Thanks again.