Created
July 13, 2023 19:10
-
-
Save KristaButler/8b46fad95ca523930e87a3d40398c565 to your computer and use it in GitHub Desktop.
Return to Same Page after Registration
This file contains 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
function mepr_cust_registration_input($product_id) { | |
global $post; | |
$input_str = "<input type='hidden' name='mepr_cust_current_page_id' id='mepr_cust_current_page_id' value='{$post->ID}'/>"; | |
echo $input_str; | |
} | |
add_action('mepr-checkout-before-submit', 'mepr_cust_registration_input'); | |
function mper_cust_thankyou_url_params($url, $args) { | |
if (isset($_REQUEST['mepr_cust_current_page_id']) && $_REQUEST['mepr_cust_current_page_id']) { | |
$param_str = http_build_query($args); | |
$url = get_permalink($_REQUEST['mepr_cust_current_page_id']); | |
if(strpos($url, '?')) { | |
$url .= '&'; | |
} else { | |
$url .= '?'; | |
} | |
$url .= $param_str; | |
} | |
return $url; | |
} | |
add_filter('mepr-thankyou-page-url', 'mper_cust_thankyou_url_params', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment