How to Redirect User to a Custom Page After Login Into Your WordPress Website

There is an unwritten rule in eCommerce that you should create conditions so that users spend more time in the store. They should spend time either buying products or browsing your site. One such condition is to redirect user after login.

The ability to redirect users after login is an important feature for both WordPress and WooCommere sites. For eCommerce stores, it helps increase sales by redirecting users directly to the shop page or to a special discounts (coupon) page.

It not only offers a better customer experience but also increases the likelihood of seeing products they might like. Otherwise, if you don't set up user registration redirect after login to a custom page, users may end up seeing the back-end of your site. Ultimately leading to a poor customer experience.

So, today we will go over how to redirect users after successful login in your WordPress site. We will show two ways-

  • Using custom code
  • Using a plugin.

Let's get into the tutorial.

Redirecting Users to a Custom Page After Login

How to Redirect User to a Custom URL After Login

As WordPress is open-source software, you can use custom coding to make the necessary customizations.

So, before we show you the use of a plugin, we will show you how to use coding in order to get the job done.

Method 1: Redirect Users Using Custom Code

Your steps would be-

  • Step1: Create a Child Theme
  • Step2: Copy the Code in the Child Theme's Function.PHP File
  • Step3: Save the Code and Test by Logging in As a Customer

Step 1: Create a Child Theme

As always, when you are making customizations, it is better to use your child theme. That way you won't lose any data when you update the plugins.

Read: How to Create a Child Theme for Your WordPress Website.

You will find plugins to create a child theme as well.

Create a folder for child theme

Step 2: Copy the Code in the Child Theme's Function.PHP File

Now, open your child theme's function.php file and copy the following code,

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' );

Step 3: Save the Code and Test by Logging in As a Customer

You are done. Now save the code and refresh your website. To test the customization, try logging in as a guest user and you will see that you will be redirected to the shop page.

However, this code won't work when a customer tries to log in from the checkout page. Because if the customer is redirected to the shop page after logging in from the checkout page, it can have a negative impact on your sales.

Method 2: Redirect Users Using A WordPress Plugin

But, if the code is looking too complicated and you don't want to get into customizations, then you can always use a plugin to get your job done. You can use the WP User Frontend plugin in order to redirect users to a custom page after login in from the login page.

Let's see the steps-

  • Step1: Install the WP User Frontend Plugin
  • Step2: Select the Redirect Page or Any Custom Page
  • Step3: Save the Configuration and Enjoy!

Step 1: Install the WP User Frontend Plugin

The first task is simple. Install the free plugin from the WordPress repository. the plugin will help your user to redirect to any WordPress page after login. This free version works with WooCommerce also.

So, go to WP-Admins–> Plugins–> Add New. Type WP User Frontend in the search box. Install and activate the plugin.

activate plugins

Step 2: Select the Redirect Page or Any Custom Page

Navigate to User Frontend–> Settings–> Login/Registration. Now select the page you want to redirect your users to after a successful registration. You will find all the pages in the dropdown menu. Select the one and hit the Save button.

redirect users

Step 3: Save the Configuration and Enjoy!

After configuring your settings, click the Save button and your users will be redirected to your selected page.

This is how you can redirect users after login on your WooCommerce store.

Configure Login Redirect for WooCommerce Right Away & Elevate User Experience!

If you follow the above tutorial, then you now know how to redirect user after login. With login redirect feature, you will have,

  • Comprehensive control over your pages. Redirect helps you to have entire control over which pages visitors are about to see after they log in. Therefore, this offers a great opportunity for your website.
  • Motivating users to visit a certain page. For example, if you have a discount page, then you can easily redirect users to visit that page, right after login.

In short, redirecting to another page after login has become more and more critical for WooCommerce stores. 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.

If you have any confusion, do let us know. We will get back to you.

Subscribe to weDevs blog

We send weekly newsletter, no spam for sure

Rabbir Shad
Written by

Rabbir Shad

Shad is a Content Writer with expertise in eCommerce, SEO, WordPress, and Technology. He has a passion for Football. Besides, he likes to spend time reading a quality book or watching any classic film.

Have something to say? Cancel Reply

Your email address will not be published.

Table of Contents