‘level’ GET parameter not taken into account on [pmpro_checkout] page
-
Dear PMPro folks,
I’m running into a bit of a head-scratcher while trying to set up PMPro in a testing environment. It seems that the Membership Checkout Page ([pmpro_checkout]) isn’t correctly taking into account the requested membership level that a user selects in the previous ([pmp_levels]) page. This despite the GET parameter being visible in my browser navigation bar (domain.tld/dir/subdir/?level=n). Instead, the [pmppro_checkout] page is always displayed as if n=1. My membership levels have IDs 1, 2, 3 and 4.
My site is running WordPress v5.5, on top of Nginx. Enabling WP_DEBUG does not produce any error messages on these two pages (or elsewhere on the site, AFAICT). I’ve disabled all other plugins to no avail.
I would greatly appreciate any pointers or insights as to what is happening under the hood, or how to fix it.
Regards,
-
Hi again,
I hate to be rude and self-bump my own thread, but knowing whether I can expect an answer in the next few days would be very useful to me and my project. If support staff are to be unavailable during that period of time, I would really appreciate if someone would simply let me know about it, too. My organization will be needing to go live with some kind of paid subscription solution by the end of this week. If our purchasing of a PMPro Plus license would guarantee us a resolution within that time frame or just about, I would be interested in knowing about it as well, as this is something that might be green-lit.
Best regards,
Hi @lzapad
Thank you for using Paid Memberships Pro, I’m really sorry for the issue you are facing here.
This sounds like it is a site-specific issue. I’d be more than happy to take a look at your site (your level’s and checkout pages) to try and see what is causing this issue.
We do not give any timeframes/guarantees when a bug/issue will be fixed. We do try our best to resolve all issues as swiftly as possible.
Is it possible to get a link to your levels page in question so I can run some tests from my end?
Some things to look into:
* Maybe your permalink rules need to be flushed. Go to the Settings -> Permalinks and click save to refresh them.
* Do you have any other plugins active that might be using the ‘level’ parameter? We have a known conflict with plugins that create a CPT named level or something like that.
@andrewza, thank your for your proposition to look into things. I have asked the site manager whether granting you access is feasible.
@strangerstudios, thank you for these pointers. I have refreshed all permalinks, but the issue remains. Here are the other plugins that are installed on this WordPress instance:
? Classic Editor
? Give – Donation plugin (which we have disabled)
? Jetpack
? Loco Translate (disabled)
? WP Super Cache (disabled)As for PMPro-tied plugins (add-ons?), none of the 76 ones present are listed as active. In fact they are all listed as being ‘Not Installed’.
Please do not share login credentials on www.ads-software.com, these are public forums and go against the guidelines.
I just need a link to the front-end of your site so I can run some tests with your caching.
Following up, here’s what I’ve managed to determine:
? The WordPress ‘Post Name’ permalink structure is playing a role in this. Setting the permalinks to a ‘Plain’ structure (https://site.tld/?page_id=nnn) caused the problem to vanish entirely.
? This issue is indeed caused by the ‘level’ HTTP GET parameter not being properly passed to the the PHP $_REQUEST variable. Where exactly in this stack this is happening, I can’t say.
? One odd observation that might help someone pinpoint the root of this behavior: while using ‘Post Name’ permalinks, a bit of debugging allowed me to observe that passing a dummy GET parameter before ‘level’ enables the software to take it into account. For example : calling https://site.tld/membership-account/membership-checkout/?dummy=yesplease&level=5 causes the Membership Checkout page to be displayed as expected.
? Relevant places in the code to patch a quick and dirty workaround :
?function pmpro_url()
insidefunctions.php
? perhaps, although I’m not really sure about that one : functionpmpro_getCheckoutButton()
My sincere gratitude to @andrewza, who spent close to 2 hours helping me with the issue, talking me through a bunch of items to check, showing me how to easily take a peek at variables without resorting to heavy duty debugging software, and pointing me towards the point in the code mentioned previously. I would not have been able to zoom in on the right part of the problem and smooth this out without all this effort. Thank you. As this definitely qualified as “pointers and insights as to what is happening under the hood, or how to fix it”, I’m marking this thread as resolved.
Cheers,
LucasHere is a patch to work around this by passing a dummy parameter in every constructed URL that uses the ‘level’ GET parameter. With this I am able to use the nicer-looking permalinks with PMPro.
diff -ruN paid-memberships-pro.orig/adminpages/discountcodes.php paid-memberships-pro/adminpages/discountcodes.php --- paid-memberships-pro.orig/adminpages/discountcodes.php 2020-08-25 23:36:48.463596205 +0200 +++ paid-memberships-pro/adminpages/discountcodes.php 2020-08-26 00:40:35.076756172 +0200 @@ -845,7 +845,7 @@ $level_names = array(); foreach( $levels as $level ) { - $level_names[] = '<a title="' . pmpro_url( 'checkout', '?level=' . $level->id . '&discount_code=' . $code->code) . '" target="_blank" href="' . pmpro_url( 'checkout', '?level=' . $level->id . '&discount_code=' . $code->code) . '">' . $level->name . '</a>'; + $level_names[] = '<a title="' . pmpro_url( 'checkout', '?prm=lvl&level=' . $level->id . '&discount_code=' . $code->code) . '" target="_blank" href="' . pmpro_url( 'checkout', '?prm=lvl&level=' . $level->id . '&discount_code=' . $code->code) . '">' . $level->name . '</a>'; } if( $level_names ) { echo implode( ', ', $level_names ); diff -ruN paid-memberships-pro.orig/classes/gateways/class.pmprogateway_paypalexpress.php paid-memberships-pro/classes/gateways/class.pmprogateway_paypalexpress.php --- paid-memberships-pro.orig/classes/gateways/class.pmprogateway_paypalexpress.php 2020-08-25 23:42:14.676221575 +0200 +++ paid-memberships-pro/classes/gateways/class.pmprogateway_paypalexpress.php 2020-08-26 00:40:35.088756051 +0200 @@ -538,11 +538,11 @@ if(!empty($order->discount_code)) { - $nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $order->membership_level->id . "&discount_code=" . $order->discount_code . "&review=" . $order->code)); + $nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?prm=lvl&level=" . $order->membership_level->id . "&discount_code=" . $order->discount_code . "&review=" . $order->code)); } else { - $nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?level=" . $order->membership_level->id . "&review=" . $order->code)); + $nvpStr .= "&ReturnUrl=" . urlencode(pmpro_url("checkout", "?prm=lvl&level=" . $order->membership_level->id . "&review=" . $order->code)); } $additional_parameters = apply_filters("pmpro_paypal_express_return_url_parameters", array()); diff -ruN paid-memberships-pro.orig/classes/gateways/class.pmprogateway_twocheckout.php paid-memberships-pro/classes/gateways/class.pmprogateway_twocheckout.php --- paid-memberships-pro.orig/classes/gateways/class.pmprogateway_twocheckout.php 2020-08-25 23:39:27.569950936 +0200 +++ paid-memberships-pro/classes/gateways/class.pmprogateway_twocheckout.php 2020-08-26 00:40:35.084756091 +0200 @@ -272,7 +272,7 @@ 'currency_code' => $pmpro_currency, 'pay_method' => 'CC', 'purchase_step' => 'billing-information', - 'x_receipt_link_url' => admin_url("admin-ajax.php") . "?action=twocheckout-ins" //pmpro_url("confirmation", "?level=" . $order->membership_level->id) + 'x_receipt_link_url' => admin_url("admin-ajax.php") . "?action=twocheckout-ins" //pmpro_url("confirmation", "?prm=lvl&level=" . $order->membership_level->id) ); //taxes on initial amount diff -ruN paid-memberships-pro.orig/includes/functions.php paid-memberships-pro/includes/functions.php --- paid-memberships-pro.orig/includes/functions.php 2020-08-25 23:43:54.751185266 +0200 +++ paid-memberships-pro/includes/functions.php 2020-08-26 00:40:35.104755891 +0200 @@ -2303,7 +2303,7 @@ } if ( ! empty( $level_id ) ) { - $r = '<a href="' . pmpro_url( 'checkout', '?level=' . $level_id ) . '" class="' . $classes . '">' . $button_text . '</a>'; + $r = '<a href="' . pmpro_url( 'checkout', '?prm=lvl&level=' . $level_id ) . '" class="' . $classes . '">' . $button_text . '</a>'; } else { $r = '<a href="' . pmpro_url( 'checkout' ) . '" class="' . $classes . '">' . $button_text . '</a>'; } diff -ruN paid-memberships-pro.orig/pages/billing.php paid-memberships-pro/pages/billing.php --- paid-memberships-pro.orig/pages/billing.php 2020-08-25 23:48:16.540472157 +0200 +++ paid-memberships-pro/pages/billing.php 2020-08-26 00:40:35.080756132 +0200 @@ -28,7 +28,7 @@ //Make sure the $level object is a valid level definition if(!empty($levels) ) { $level = $levels[0]; - $checkout_url = pmpro_url( 'checkout', '?level=' . $level->id ); + $checkout_url = pmpro_url( 'checkout', '?prm=lvl&level=' . $level->id ); $logout_url = wp_logout_url( $checkout_url ); ?> <p><?php printf(__("Logged in as <strong>%s</strong>.", 'paid-memberships-pro' ), $current_user->user_login);?> <small><a href="<?php echo esc_url( $logout_url ); ?>"><?php _e("logout", 'paid-memberships-pro' );?></a></small></p> @@ -442,10 +442,10 @@ // Show the correct checkout link. if ( ! empty( $level ) && ! empty( $level->allow_signups ) ) { - $url = pmpro_url( 'checkout', '?level=' . $level->id ); + $url = pmpro_url( 'checkout', '?prm=lvl&level=' . $level->id ); printf( __( "Your membership is not active. <a href='%s'>Renew now.</a>", 'paid-memberships-pro' ), $url ); } elseif ( ! empty( $default_level_id ) ) { - $url = pmpro_url( 'checkout', '?level=' . $default_level_id ); + $url = pmpro_url( 'checkout', '?prm=lvl&level=' . $default_level_id ); printf( __( "You do not have an active membership. <a href='%s'>Register here.</a>", 'paid-memberships-pro' ), $url ); } else { $url = pmpro_url( 'levels' ); diff -ruN paid-memberships-pro.orig/pages/checkout.php paid-memberships-pro/pages/checkout.php --- paid-memberships-pro.orig/pages/checkout.php 2020-08-25 23:35:20.240507927 +0200 +++ paid-memberships-pro/pages/checkout.php 2020-08-26 00:40:35.080756132 +0200 @@ -20,7 +20,7 @@ } ?> <div id="pmpro_level-<?php echo $pmpro_level->id; ?>" class="<?php echo pmpro_get_element_class( $pmpro_checkout_gateway_class, 'pmpro_level-' . $pmpro_level->id ); ?>"> -<form id="pmpro_form" class="<?php echo pmpro_get_element_class( 'pmpro_form' ); ?>" action="<?php if(!empty($_REQUEST['review'])) echo pmpro_url("checkout", "?level=" . $pmpro_level->id); ?>" method="post"> +<form id="pmpro_form" class="<?php echo pmpro_get_element_class( 'pmpro_form' ); ?>" action="<?php if(!empty($_REQUEST['review'])) echo pmpro_url("checkout", "?prm=lvl&level=" . $pmpro_level->id); ?>" method="post"> <input type="hidden" id="level" name="level" value="<?php echo esc_attr($pmpro_level->id) ?>" /> <input type="hidden" id="checkjavascript" name="checkjavascript" value="1" /> @@ -111,7 +111,7 @@ <hr /> <h3> <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-name' ); ?>"><?php _e('Account Information', 'paid-memberships-pro' );?></span> - <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><?php _e('Already have an account?', 'paid-memberships-pro' );?> <a href="<?php echo wp_login_url( apply_filters( 'pmpro_checkout_login_redirect', pmpro_url("checkout", "?level=" . $pmpro_level->id . $discount_code_link) ) ); ?>"><?php _e('Log in here', 'paid-memberships-pro' );?></a></span> + <span class="<?php echo pmpro_get_element_class( 'pmpro_checkout-h3-msg' ); ?>"><?php _e('Already have an account?', 'paid-memberships-pro' );?> <a href="<?php echo wp_login_url( apply_filters( 'pmpro_checkout_login_redirect', pmpro_url("checkout", "?prm=lvl&level=" . $pmpro_level->id . $discount_code_link) ) ); ?>"><?php _e('Log in here', 'paid-memberships-pro' );?></a></span> </h3> <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-fields' ); ?>"> <div class="<?php echo pmpro_get_element_class( 'pmpro_checkout-field pmpro_checkout-field-username', 'pmpro_checkout-field-username' ); ?>"> diff -ruN paid-memberships-pro.orig/pages/levels.php paid-memberships-pro/pages/levels.php --- paid-memberships-pro.orig/pages/levels.php 2020-08-25 23:44:51.246600030 +0200 +++ paid-memberships-pro/pages/levels.php 2020-08-26 00:40:35.080756132 +0200 @@ -66,16 +66,16 @@ </td> <td> <?php if(empty($current_user->membership_level->ID)) { ?> - <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a> + <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?prm=lvl&level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a> <?php } elseif ( !$current_level ) { ?> - <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a> + <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?prm=lvl&level=" . $level->id, "https")?>"><?php _e('Select', 'paid-memberships-pro' );?></a> <?php } elseif($current_level) { ?> <?php //if it's a one-time-payment level, offer a link to renew if( pmpro_isLevelExpiringSoon( $current_user->membership_level) && $current_user->membership_level->allow_signups ) { ?> - <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?level=" . $level->id, "https")?>"><?php _e('Renew', 'paid-memberships-pro' );?></a> + <a class="<?php echo pmpro_get_element_class( 'pmpro_btn pmpro_btn-select', 'pmpro_btn-select' ); ?>" href="<?php echo pmpro_url("checkout", "?prm=lvl&level=" . $level->id, "https")?>"><?php _e('Renew', 'paid-memberships-pro' );?></a> <?php } else { ?> diff -ruN paid-memberships-pro.orig/preheaders/checkout.php paid-memberships-pro/preheaders/checkout.php --- paid-memberships-pro.orig/preheaders/checkout.php 2020-08-25 23:49:59.987399221 +0200 +++ paid-memberships-pro/preheaders/checkout.php 2020-08-26 00:40:35.080756132 +0200 @@ -753,7 +753,7 @@ } //redirect to confirmation - $rurl = pmpro_url( "confirmation", "?level=" . $pmpro_level->id ); + $rurl = pmpro_url( "confirmation", "?prm=lvl&level=" . $pmpro_level->id ); $rurl = apply_filters( "pmpro_confirmation_url", $rurl, $user_id, $pmpro_level ); wp_redirect( $rurl ); exit; diff -ruN paid-memberships-pro.orig/preheaders/levels.php paid-memberships-pro/preheaders/levels.php --- paid-memberships-pro.orig/preheaders/levels.php 2020-08-25 23:49:11.395903263 +0200 +++ paid-memberships-pro/preheaders/levels.php 2020-08-26 00:40:35.080756132 +0200 @@ -12,7 +12,7 @@ $default_level = false; if ($default_level) { - wp_redirect(pmpro_url("checkout", "?level=" . $default_level)); + wp_redirect(pmpro_url("checkout", "?prm=lvl&level=" . $default_level)); exit; } diff -ruN paid-memberships-pro.orig/services/twocheckout-ins.php paid-memberships-pro/services/twocheckout-ins.php --- paid-memberships-pro.orig/services/twocheckout-ins.php 2020-08-25 23:50:54.262836099 +0200 +++ paid-memberships-pro/services/twocheckout-ins.php 2020-08-26 00:40:34.956757375 +0200 @@ -66,7 +66,7 @@ inslog( "ERROR: Couldn't change level for order (" . $morder->code . ")." ); } - pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id)); + pmpro_twocheckoutExit(pmpro_url("confirmation", "?prm=lvl&level=" . $morder->membership_level->id)); } // First Payment (checkout) (Will probably want to update order, but not send another email/etc) @@ -90,7 +90,7 @@ inslog( "ERROR: Couldn't change level for order (" . $morder->code . ")." ); } - pmpro_twocheckoutExit(pmpro_url("confirmation", "?level=" . $morder->membership_level->id)); + pmpro_twocheckoutExit(pmpro_url("confirmation", "?prm=lvl&level=" . $morder->membership_level->id)); } // Recurring Payment Success (recurring installment success and recurring is true) diff -ruN paid-memberships-pro.orig/shortcodes/pmpro_account.php paid-memberships-pro/shortcodes/pmpro_account.php --- paid-memberships-pro.orig/shortcodes/pmpro_account.php 2020-08-25 23:52:07.482092021 +0200 +++ paid-memberships-pro/shortcodes/pmpro_account.php 2020-08-26 00:40:35.080756132 +0200 @@ -64,10 +64,10 @@ // Show the correct checkout link. if ( ! empty( $level ) && ! empty( $level->allow_signups ) ) { - $url = pmpro_url( 'checkout', '?level=' . $level->id ); + $url = pmpro_url( 'checkout', '?prm=lvl&level=' . $level->id ); printf( __( "Your membership is not active. <a href='%s'>Renew now.</a>", 'paid-memberships-pro' ), $url ); } elseif ( ! empty( $default_level_id ) ) { - $url = pmpro_url( 'checkout', '?level=' . $default_level_id ); + $url = pmpro_url( 'checkout', '?prm=lvl&level=' . $default_level_id ); printf( __( "You do not have an active membership. <a href='%s'>Register here.</a>", 'paid-memberships-pro' ), $url ); } else { $url = pmpro_url( 'levels' );
Thanks for the feedback Lucas, I’m glad that I could be helpful. If you have any further questions please do not hesitate to open a new support ticket.
- The topic ‘‘level’ GET parameter not taken into account on [pmpro_checkout] page’ is closed to new replies.