Created
January 9, 2020 20:02
-
-
Save dparker1005/bc67b0a756cb2d8c042134e5ed9b5f50 to your computer and use it in GitHub Desktop.
Redirect away from the checkout page if a specific parameter is not in the URL
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
| <?php | |
| // Copy from below here... | |
| /* | |
| * Redirect away from the checkout page if a specific parameter is not in the URL | |
| */ | |
| function my_pmpro_require_url_param_for_checkout() | |
| { | |
| $request_key = 'checkout_password'; | |
| $request_value = 'my_password'; | |
| // With defaults set above, a sample checkout URL that would be allowed at checkout is | |
| // www.yoursite.com/membership-account/membership-checkout/?level=1&checkout_password=my_password | |
| global $pmpro_pages; | |
| if( empty( $pmpro_pages ) ) | |
| return; | |
| if ( is_page( $pmpro_pages['checkout'] ) && ( empty( $_REQUEST[ $request_key ] ) || $_REQUEST[ $request_key ] !== $request_value ) ) { | |
| wp_redirect( site_url( 'page-explaining-you-need-level-1-first' ) ); //change url here | |
| exit; | |
| } | |
| } | |
| add_action('template_redirect', 'my_pmpro_require_url_param_for_checkout'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment