Allow registration to redirect to same page

Fixes #16889
This commit is contained in:
Gary Ritchie 2017-09-21 20:50:45 -07:00
parent abc43c473e
commit a25d3c8af4
1 changed files with 9 additions and 1 deletions

View File

@ -1086,7 +1086,15 @@ class WC_Form_Handler {
wc_set_customer_auth_cookie( $new_customer );
}
wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( 'myaccount' ) ) );
if ( ! empty( $_POST['redirect'] ) ) {
$redirect = $_POST['redirect'];
} elseif ( wc_get_raw_referer() ) {
$redirect = wc_get_raw_referer();
} else {
$redirect = wc_get_page_permalink( 'myaccount' );
}
wp_redirect( wp_validate_redirect( apply_filters( 'woocommerce_registration_redirect', $redirect ), wc_get_page_permalink( 'myaccount' ) ) );
exit;
} catch ( Exception $e ) {