• Dear woocommerce,
    When we login to customer role logout redirect to home page instead of my account page.

    Advance Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    Add this snippet inside your theme’s functions.php file. It should redirect users with customer role to homepage.

    add_filter( 'woocommerce_login_redirect', 'dokan_after_login_redirect' , 1, 2 );
    function dokan_after_login_redirect( $redirect_to, $user ) {
        if ( in_array( 'customer', (array) $user->roles ) ) {
            return home_url();
        }
        return $redirect_to;
    }
    

    Thanks

    Thread Starter muprabakaran

    (@muprabakaran)

    Thanks for your Response. Mr.Rafsun Chowdhury
    logout redirect to my account page we need how to redirect to home page instead of my account page.

    Hi,

    You can use the wp_logout action for that.

    Try this :

    add_action( 'wp_logout', 'custom_logout_redirect', 99 );
    function custom_logout_redirect() {
        wp_redirect(home_url());
    }
     

    Let me know if it has worked for you.
    Thanks

    Thread Starter muprabakaran

    (@muprabakaran)

    Thanks for your valuable time for reply sir.

    We can user wp_logout code but customer logout redirect to my page not redirect to home page.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Customer redirect’ is closed to new replies.