After a user registers using WooCommerce's registration form, I want to redirect them to a custom page, such as my other website, instead of the my-account page.

add_action('woocommerce_registration_redirect', 'ps_wc_registration_redirect',10); 
function ps_wc_registration_redirect( $redirect_to ) {  
    $redirect_to ="http://example.com";
    return $redirect_to;

The hook above successfully redirects users when the destination is a page on the current site, but when the redirect location is off of the current site, it does not work.

Is there any other hook available after the user registration redirection occurs?

2 Answers 2


Internally, WooCommerce uses WordPress' wp_safe_redirect() which does not allow redirects to external hosts. In order to get around this, we must add our desired host to the whitelist. The whitelist can be modified using the allowed_redirect_hosts which has been demonstrated below:

 * Adds example.com to the list of allowed hosts when redirecting using wp_safe_redirect()
 * @param array       $hosts An array of allowed hosts.
 * @param bool|string $host  The parsed host; empty if not isset.
add_filter( 'allowed_redirect_hosts', 'wpse_allowed_redirect_hosts', 10, 2 );
function wpse_allowed_redirect_hosts( $hosts, $host ) {
    $hosts[] = 'example.com';

    return $hosts;

Use the code above along with your original code (customizing the host as needed) to allow WooCommerce users to be redirected to an external domain after completing the registration process.

  • Thank you for you response add_action('woocommerce_registration_redirect', 'ps_wc_registration_redirect',10); function ps_wc_registration_redirect( $redirect_to ) { $redirect_to ="example.com"; return $redirect_to; } This code is used to redirect after woocommerce registration how can i use your code into the "woocommerce_registration_redirect" hook. Jul 3, 2017 at 4:30
  • Use your original code in addition to what I posted. wpse_allowed_redirect_hosts() whitelists the domain and ps_wc_registration_redirect() sets the location for the redirect. Jul 3, 2017 at 4:48
  • add_filter('woocommerce_registration_redirect', 'bryce_wc_register_redirect'); function bryce_wc_register_redirect( $redirect_to ) { $redirect_to="zmanager.zenvus.com"; return $redirect_to; } add_filter( 'allowed_redirect_hosts', 'wpse_allowed_redirect_hosts',10,2 ); function wpse_allowed_redirect_hosts( $redirect ) { $redirect[] = "zmanager.zenvus.com"; return $redirect; } i have put this code like this but it not working. can you please help me Thank you in advance!! Jul 3, 2017 at 5:15
  • Please edit your original question and add the code you're using there and explain what not working means exactly. It's hard to read code in comments. BTW, I did test the code before posting and it worked for me. We'll get it! Jul 3, 2017 at 5:23
  • 1
    Thank you for your support yeah i have customize code and its working!! Jul 3, 2017 at 5:27

try setting the function as below, also there is no need of parameter to the function if you are manually setting the link in the function

function custom_registration_redirect_after_registration() {
    return home_url('/post_slug_or_page_slug');
add_action('woocommerce_registration_redirect', 'custom_registration_redirect_after_registration', 2);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.