Redirect Users After WooCommerce Login or Registration

It’s possible to redirect your users to a page other than My Account when they login or register. Try adding the following code using the Code Snippets plugin, or via your preferred method.

Redirect at Login

To redirect at login, you need to use the woocommerce_login_redirect filter.

First of all, we’re checking whether the attempted redirect is for the checkout page; this catches users who are logging in at checkout, as it’s likely they will want to go back there and not some other page on the site. If they’re not at checkout, we redirect them to the WooCommerce shop page. You could even use the $user variable to redirect users based on their capabilities.

Redirect after Registration

To redirect after registration, you need to use the woocommerce_registration_redirect filter.


Leave a Reply

10 Comments on "Redirect Users After WooCommerce Login or Registration"

newest oldest most voted
Notify of

Hey, the redirect at login is exactly what I was looking for. Unfortunately this code breaks my site, and I cannot see where the problem lies.

Brodie Brodie

A semi colon was missing, this code works.
* Redirect to shop after login.
* @param $redirect
* @param $user
* @return false|string
function iconic_login_redirect( $redirect, $user ) {
$redirect_page_id = url_to_postid( $redirect );
$checkout_page_id = wc_get_page_id( ‘checkout’ );

if( $redirect_page_id == $checkout_page_id ) {
return $redirect;

return wc_get_page_permalink( ‘shop’ );

add_filter( ‘woocommerce_login_redirect’, ‘iconic_login_redirect’ );


Hi ! Sorry I am a beginner at Woocommerce, website codes, etc. Could you tell me where I should write the code you gave ? Inside what folder, what file ?

Edwin Bollen

Either place this in the functions.php file or as James mentions use the Code Snippets plugin. (I prefer to use the last option)


Got a function which makes all accounts inactive after registration and after that, wp_logout() runs and after that, a redirect to the my account page. Since the user now is registered, logged out and re-directed back to the “My account” page where the login and register form is, do you know how to print a notice message on that page considering the session has ended?

I’ve tried using this:
if ( ! WC()->session->has_session() ) {

But that does not help. Any ideas or advice?

Hi, when I put this my checkout page gives a white page. Also what I really want is that when people come to the checkout page and they are not logged in the are redirected to the my account page to login first and when logged in they automatically come back to the checkout page. The first part I have, but how to redirect back to the checkout page is missing. Can you give me a hint? All the best, Luc //Woocommerce visible only to logged-in users function wpse_1_redirect() { if ( ! is_user_logged_in() && (is_checkout()) ) { // customize… Read more »