Woocommerce redirect after registration Woocommerce redirect after registration wordpress wordpress

Woocommerce redirect after registration


Important update (working on last version 3.2.x)


First the woocommerce_registration_redirect is a filter hook, but NOT an action hook.

A filter hook has always at least one argument and always require to return something. It can be the main function argument (the first one) or some custom value.

The correct tested and functional code is:

add_filter( 'woocommerce_registration_redirect', 'custom_redirection_after_registration', 10, 1 );function custom_redirection_after_registration( $redirection_url ){    // Change the redirection Url    $redirection_url = get_home_url(); // Home page    return $redirection_url; // Always return something}

Code goes in function.php file of your active child theme (or theme)...


Some common redirections urls used in woocommerce:

  • Get the "Home" page Url: $redirection_url = get_home_url();
  • Get the "Shop" page url: $redirection_url = get_permalink( wc_get_page_id( 'shop' ) );
  • Get the "Cart" page Url: $redirection_url = wc_get_cart_url();
  • Get the "Checkout" page Url: $redirection_url = wc_get_checkout_url();
  • Get the "My account" or registration page Url:
    $redirection_url = get_permalink( wc_get_page_id( 'myaccount' ) );
  • Get other post or pages by ID: $redirection_url = get_permalink( $post_id );
    (where $post_id is the id of the post or the page)
  • Get post or pages by path (example): $redirection_url = home_url('/product/ninja/');


The accepted answer didn’t work for me. What worked for me was this:

// After registration, logout the user and redirect to home pagefunction custom_registration_redirect() {    wp_logout();    return home_url('/');}add_action('woocommerce_registration_redirect', 'custom_registration_redirect', 2);


You want to use a filter like this:

function plugin_registration_redirect() {    return home_url( '/page-to-show' );}add_filter( 'registration_redirect', 'plugin_registration_redirect' );

Or, specifically to your code:

function plugin_registration_redirect() {    $url = wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( 'welcome' );    return $url;}add_filter( 'registration_redirect', 'plugin_registration_redirect' );