Skip to content

Instantly share code, notes, and snippets.

@labsecrets
Forked from strangerstudios/gist:5573829
Last active August 29, 2015 14:06
Show Gist options
  • Save labsecrets/bf0a1b25f47ab5ee78b4 to your computer and use it in GitHub Desktop.
Save labsecrets/bf0a1b25f47ab5ee78b4 to your computer and use it in GitHub Desktop.
/*
Only let level 1 members 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 == 1 && (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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment