Home > WooCommerce > Docs > How to Redirect to Another Page after Login in WooCommerce

How to Redirect to Another Page after Login in WooCommerce

Last updated: August 01, 2024
Written and researched by experts at AvadaLearn more about our methodology

By Sam Nguyen

CEO Avada Commerce

Are you fond of redirecting visitors to your WooCommerce site to the exact location that you want? As WordPress does not come with the function to perform this activity, you might think that it is impossible to do so. But the reality is you could do it by reading through our simple instructions.

Now do not hesitate to follow us on how to redirect to another page after login in WooCommerce, and you will find it powerful to send your customers to the right locations. Then, you will have more control of who is on your site and what they will exactly do.

The importance of redirecting after login in WooCommerce

Redirecting after login is undoubtedly crucial within your WooCommerce, and it is a must thing to do if you want to give your customers a unique shopping experience. So, now let’s see why you should implement such redirects as well as their undeniable significance.

  • Have comprehensive control of your pages: Redirects help you have entire control over which pages visitors are about to see after they log in. Therefore, this offers a great opportunity for your website.

  • Encourage visitors to enter a certain page: By redirecting, you can send users to a certain page as your need immediately.

How to redirect to another page after login in WooCommerce?

It is time to learn how you could redirect to another page after logging in. In this topic, we mention two methods, including using code snippet if you are keen on it and using a plugin if you are not keen on coding.

1. Apply code snippet

In the first method, there is no need to be fluent at coding as you only have to copy the provided code and paste it to your functions.php file. By default, a similar page will get reloaded when the users log in from their page “My Account”. To be more specific, add the below code snippet to the child theme.

My Account

As you could notice from the above code, the hook woocommerce_login_redirect will be applied to perform this. Thanks to this code, you aim at redirecting users to your Shop page as soon as they log in, only when they are not on the page Checkout.



function ts_redirect_login( $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', 'ts_redirect_login' );


This is to say when customers check out after login, they are not redirected to your Shop page. Thanks to this added condition, the process of users’ payment becomes more smoothy, thereby decreasing the likelihood of losing your sale.

By assigning the value “Shop”, which this value can be the relative URL pointing to your store, you are redirecting users to your store, and any URL could substitute this. What’s more, owing to this code, users could be taken to your store after the login instead of going to your Checkout page. This way also helps you to redirect them to any wanted page to your need after a login.

2. Use a plugin

If you are not fond of using code snippets and are looking for a faster and more effective method, using a plugin would benefit you. In this case, we will walk through how to redirect to another page after login in WooCommerce with the help of Peter’s Login Redirect. Thanks to it, you could be able to redirect your users to any popular products that are available on your WooCommerce site.

Step 1: Activate the plugin Peter’s Login Redirect

The first and foremost step is to get the plugin Peter’s Login Redirect installed and activated. This plugin offers available and flexible options to meet your need in accomplishing any task. It comes with a wide range of customization and options for developers. Whether you want to redirect after logging in or registration, Peter’s Login Redirect, as its name indicates, would handle well.

Begin your process by hitting on the section “Plugins” and choose the option “Add New” on the left side of your admin panel.

Install the plugin Peter’s Login Redirect

Now, you can notice the search box on your right side to search for this plugin. Enter Peter’s Login Redirect, and this pulls up extra valuable plugins that you could use.

Install activate the plugin Peter’s Login Redirect

And the result of this plugin will appear on the top. When you see the plugin, select the button “Install Now”, then “Activate” for use.

Install activate the plugin Peter’s Login Redirect

Step 2: Perform your redirects

It is time to perform your redirects. Specifically, this plugin will separate users’ logins into five different categories, including Specific Users, Specific Levels, Specific Roles, Post Registration, and Other Users. Each type of option will let you implement the customization of logins to match the visitors that it affects.

Proceed to the next step by hitting on the section “Settings” and choose the option “Login/Logout Redirects”. Check out the following screen to understand deeper.

Perform your redirects

All those roles come with sections for “Logout URL”, along with “URL”. These sections facilitate the process of placing your page’s web address that you are about to redirect your users to. Let us take an example, you can choose to set up one WordPress login that then redirects to your homepage by using https://www.YourHomePage.com in these areas. You can replace the portion “YourHomePage” with the domain name of your WooCommerce website.

To ensure a successful setting, you should go through each section and see how you could redirect to another page after login in different categories.

  • Specific users

Regarding the setting of Specific Users, it will help you control how a person will log in. Therefore, it is a helpful hand if you have some people in need of accessing a certain page right after login.

Specific users

Your dropdown window tends to expand the list of every active user of your WordPress site. Before saving what, you have made changes, remember to assign your URLs as well as hit on the option “Add username rule”.

  • Specific roles

When it comes to specific roles category, it will redirect users based on the “roles” that they are in WordPress. To be more specific, it could support you with custom roles that you have built with some other plugins. For example, you can redirect the admins to an URL while redirecting authors to another.

Specific roles

In the settings area, you will navigate to your section Specific Roles and choose a role to redirect users based on their “roles”. For instance, you could send customers and paid subscribers to specific areas of your WooCommerce site after login.

  • Specific levels

The third category you could base on to redirect to another page after logging in is Specific Levels. In this section, assigning redirects determined by permission levels given to your users is what you could execute.

Specific levels

Do you know in which case you could use specific levels to redirect users? It is helpful if you fancy particular permissions for accessing a page. However, you are not keen on assigning your users any certain roles. In particular, it is applicable when you want a person to have a certain editor ability without enabling him/her to be an editor.

  • Other users

Besides specific roles, specific users, and specific levels, this plugin is so great that it gives you an opportunity to manage other users who are out of the above settings. Particularly, you could set specific rules for admins as well as editors while redirecting others to a different page.

Other users

It is non-compulsory because you don’t need to redirect everyone in case you select not to. Nevertheless, this option is at your disposal if you set your heart on redirecting users within WooCommerce and WordPress after logging in.

  • Post-registration

With the post-registration section, your task is to input one URL in it. This aims at redirecting users as soon as they finish registering for their accounts.

After-registration

This is similar to a page “Thank you” or the landing page of one discounted item or product. It is undeniable that it could work as great as one marketing device because you will give your users one reason for registering your website.

Step 3: Further customization

In addition to the above settings, you can even perform further customization, such as setting permission levels as well as restrictions for editing the redirects. Especially, you are also able to modify how the variables within WooCommerce and WordPress will be handled.

Now, head to the “Customize Plugin Setting” to implement some kinds of advanced changes related to how this plugin will work.

Further customization

You need to remember that only when you know what you are performing in this kind of section, might it be best for you to set it as your default settings. If you desire to test this plugin, you could create some users of distinct roles to check what their login will look like. If you use the admin account only, the likelihood is that you could not observe all the changes.

While you could give your customers an amazing experience by sending them to the right page, it is also possible to make them annoyed in case you send them to the wrong page. For example, customers can easily get annoyed when you divert them to your sales page, especially when logging in regularly.

For instance, you have one new service or product for sale, then you aim at redirecting them to that sales page. However, it seems disturbing to do so. Many of them log into your website and just wish to penetrate a certain area. Hence, you should make sure that visitors to your site can navigate easily to other website areas as well.

Top 3 plugins to redirect to another page after login in WooCommerce

Using plugins is undoubtedly a good way to customize and configure settings related to redirects successfully. So, besides the above useful plugins, we suggest you look through the other three awesome plugins that are useful for redirecting to another page after logging in to WooCommerce. Let’s see what they are and what makes them outstanding.

1. Yoast WooCommerce SEO

Yoast WooCommerce SEO is well-known for being an amazingly hassle-free plugin to control redirects of your WooCommerce store well. By helping you identify or remove irrelevant as well as old content from the site. What is more, you could also implement several automatic redirects with a view to avoiding 404 errors. In particular, this plugin also supports you to build different kinds of redirects or imports, along with exporting them via CSV files.

Yoast WooCommerce SEO

Main features

  • Allow you to import as well as export redirects

  • Offer the flexibility for scaling

  • Come with the support of the Regular Expressions redirects

  • Perform different redirects, including temporary redirects, permanent redirects, and so on.

Pricing: $69

2. Redirection

Another not-to-be-missed plugin is Redirection. As its name state, this plugin will make you good at managing 301 redirects effectively of your WooStore. There is nothing quite like tracking the errors named “404 Not Found” and the Redirection plugin is a perfect one to go. Moreover, you could be able to clean up several generic problems that could be nagging the webmaster. For those things, do not hesitate to add them to your cart and start your redirecting process.

Redirection

Main feature

  • Let you keep track of unwanted errors as well as handle them in the proper and timely manner

  • Come with the customized instructions to assist you in redirecting to a different page efficiently

  • Be able to redirect your currently existing URLs and even the non-existing ones

  • Help to maintain every redirect for reference later

  • Be able to obtain statistics of the redirect occurrences like the source in which the link is found

Pricing: Free

3. Simple 301 Redirects

The last plugin in this list is Simple 301 Redirects. Thanks to it, you are able to redirect your URLs to a different page on the WooCommerce store. It is famous for being a user-friendly plugin and helps you redirect the existing traffic or change the structure of the URL completely. What you need to do is very simple just by entering the inactive or old URL in your field Request as well as the new one in the field Destination.

Simple 301 Redirects

Main features

  • Redirect to a different page easily and quickly

  • Be useful in case the URL structure of your site is changed completely

  • Come with features and functions for easier configuration

  • Help to boost SEO rankings

  • Be user-friendly

Pricing: Free

Conclusion

In short, redirecting to another page after login has become more and more critical for any online WooCommerce store. So, you need also keep the trend to make your WooStore stand out from the crowd. Especially, these redirects bring about tons of benefits for your websites, not to mention an increase in sales. In doing so, you will have more control over your site, thus redirecting your consumers to a specific page that you want.

Hope you can find our instruction helpful for your business. Please share it with those concerned, and keep following us for more great tips and tricks in the upcoming time.


Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.

Stay in the know

Get special offers on the latest news from AVADA.