Hi there,
Thank you for getting in touch.
You are able to follow Paid Memberships Pro blog here – https://www.paidmembershipspro.com/require-a-discount-code-to-checkout-for-a-certain-level/
This touches on exactly what you are wanting to achieve, you mentioned you are using code in your functions.php, are you using the code from this blog?
The link you paste request i upgrade my membership further before seeing the code. Below is the code i’m using
******************************************************************************************
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, 3 and there is no discount code, then show an error message
global $pmpro_level, $discount_code;
//if($pmpro_level->id == 1, 3 && (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_level->id == 2 && empty($discount_code))
{
pmpro_setMessage(“You must use a valid Discount Code to register on this site.”, “pmpro_error”);
return false;
}
return $pmpro_continue_registration;
}
add_filter(“pmpro_registration_checks”, “my_pmpro_registration_checks_require_code_to_register”);
function theme_ob_get_clean() {
global $theme_ob_stack;
ob_end_flush();
return array_pop($theme_ob_stack);
}
*************************************************************************************
I’m able to bypass discount code restriction, by just entering any figures in the Discount Code field, don’t click on apply and click on “Submit and Checkout” twice it will redirect the user to confirmation and assign a membership level.
***
I think there should be an addition code that will verify the code entered in the Discount code field even if not apply.
-
This reply was modified 9 years, 4 months ago by
maundinc.
Here is a link to the gist for the code, it appears to be the same – https://gist.github.com/strangerstudios/5573829#file-gistfile1-txt
I will have a look at the code and try debug this for you – could you tell me what version of Paid Memberships Pro you are currently using?
Also regarding your code, could you please adjust it to work on only level 1 for now and not level 1 and 3.
Please test that and let me know.
Andrew thank you in advance, after adjusting to work with only level 1, am still able to bypass to confirmation page.
I am using Paid Memberships Pro Version 1.8.11.2
Hi @maundinc,
Thank you for the feedback.
I am going to try and recreate this issue on my local environment and come up with a solution for you.
Thank you for your patience.
I believe the gist file has been updated to do additional checks -> https://gist.github.com/strangerstudios/5573829#file-gistfile1-txt
You may see the comment on line 14 of the gist – hope this helps.
Hello Andrew hope you doing good, any updates on the above issue?
Hi,
I have the same problem few months. Is there already a solution please?
I have installed all updates (WP, PMPro, …).
Thank you very much for help.
Peter