Last active
November 16, 2020 07:43
-
-
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
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
/* | |
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