Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Default to the blackfriday discount code if none is set. Paid Memberships Pro
/*
Default to the blackfriday discount code if none is set.
Add this code to a custom plugin.
*/
function init_default_pmpro_discount_code() {
//edit and uncoment this line to limit this to a specific page; note that "is_page" won't work yet
//if(strpos($_SERVER['REQUEST_URI'], '/blackfriday') === false) return;
if(!isset($_REQUEST['discount_code'])) {
$_REQUEST['discount_code'] = 'blackfriday';
}
//default to level 1 as well
if(!isset($_REQUEST['level'])) {
$_REQUEST['level'] = 1;
}
}
add_action('init', 'init_default_pmpro_discount_code', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.