-
-
Save dparker1005/cd47c20d751d90015a86f44790134793 to your computer and use it in GitHub Desktop.
Require discount code on checkout
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 | |
// Copy from below here | |
/* | |
* Require that a user use a discount code when reigstering for specific levels. | |
*/ | |
function my_pmpro_registration_checks_require_code_to_register( $pmpro_continue_registration ) { | |
$restricted_levels = array( 1, 3 ); // Levels 1 and 3 require a discount code to register | |
global $discount_code, $pmpro_level; | |
if( empty( $discount_code ) && in_array( $pmpro_level->id, $restricted_levels ) ) { | |
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