Skip to content

Instantly share code, notes, and snippets.

@ideadude
Last active November 16, 2020 07:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ideadude/39d46260b9c8f56ada77ecb69d2a47b0 to your computer and use it in GitHub Desktop.
Save ideadude/39d46260b9c8f56ada77ecb69d2a47b0 to your computer and use it in GitHub Desktop.
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