Do you want to redirect users in WordPress after they log in? Redirects allow you to send a visitor to the exact location you want them. Thus, they are a powerful tool in the hand of a clever developer, but redirects are not baked into WordPress.
Thus, you are going to need a plugin that can handle redirections. There are a variety of plugins available to accomplish this task. And by using a simple plugin, you have quite a bit of control over who does what on your website.
Today, I’m going to show you how to redirect users in WordPress after a successful login.
Why You Should Redirect Users in WordPress
Why is redirecting important?
Having complete control of what pages the visitor will see after logging in provides a huge opportunity to any website. And you can even allow different visitors to see different pages. It helps streamline the user experience.
For example, you may have user-role-specific pages or posts on your website. Using a redirect on login will send those users to the specific pages immediately. This is perfect for membership websites that have different levels of membership.
Looking to cash in on an affiliate deal? Send your logged-in visitors to a specific page to encourage them to click on a link. Or perhaps you custom roles for paid content. Maybe you created private posts and want users to be redirected to that particular category.
You could also redirect users to the most popular products on your website. This is ideal for any website with a shop.
There is a lot you can do to control user interaction when logging into the system.
How to Redirect Users in WordPress After Logging In
Step 1: Install Peter’s Login Redirect Plugin
The Peter’s Login Redirect plugin offers a variety of options and customization for developers. It has several options available and is flexible in regards to what you’re trying to accomplish. Whether it’s a redirect after login or user registration, this tool handles quite a bit.
Let’s start by clicking on Plugins and selecting the Add New option on the left-hand admin panel.
Search for Peter’s Login Redirect in the available search box. This will pull up additional plugins that you may find helpful.
Scroll down until you find the Peter’s Login Redirect plugin and click on the «Install Now» button and activate the plugin for use.
Step 2: Set Up Redirects
You now need to set up your redirects. In total, the plugin separates logins into 5 distinct categories, Specific Users, Specific Roles, Specific Levels, All Other Users, and Post Registration. Each option allows you to customize the login to match the visitors it affects.
Click on Settings and select the Login/logout redirects option.
All of these roles have sections for «URL» and «Logout URL.» This is where you place the web address of the page you want to redirect users to. For instance, you can set a WordPress login to redirect to the homepage by typing: «http://www.YourHomePage.com» in either of these areas.
Of course, you want to change the «YourHomePage» portion with your domain name.
Let’s take a look at each one.
Note: Make sure to save each setting as you go through the sections. Saving a change to one of them will empty the other fields.
The Specific Users setting controls how one person logs in. This is useful if you only have a handful of people who need to access a specific page after logging in.
The drop-down window expands a list of all active users on your WordPress website. Assign the URLs and click the «Add username rule» to save the setting.
Specific role redirects users according to their «roles» in WordPress. This supports custom roles you create with other plugins. For instance, you can redirect authors to one URL and admins to another.
For example, you can send paid subscribers or customers to certain areas of the website after logging in.
In Specific Levels, you can assign redirects based on permission levels given to users. This is more in-depth and requires a bit of knowledge about how to change user levels and permissions.
This is useful when you want certain permissions to access a page but don’t want the user to have specific roles. For instance, what if you want someone to have a specific editor ability without actually making him or her an editor?
All Other Users
Peter’s Login Redirect also allows you to control other users outside of the settings above. For instance, you can set certain rules for editors and admins while redirecting everyone else to another page.
This is really an optional setting since you don’t have to redirect anyone if you choose not to. However, the option is available if you want WordPress to redirect users after they log in.
Input a URL in this section to redirect users after they register for an account.
This could be to something like a «Thank you» page or a landing page for a discounted product. It can work well as a marketing device as you give users a reason for registering on your website.
Customize Plugin Settings
In this section, you can set restrictions, permission levels required to edit redirects and change how WordPress variables are handled. Use Customize Plugin Settings for advanced changes in how the plugin works.
Unless you absolutely know what you’re doing in this section, it’s probably best to leave it as default settings.
And with all of the settings configures, the plugin is good to go. Congratulations!
Note: If you are interested in testing the plugin, simply create a few users that have different roles to check what each login looks like. If you only use your admin account, you won’t be able to see all of the changes.
Redirect Users to Pages That Make Sense
While you can certainly enhance the user experience by sending visitors to the right pages, it is also entirely possible to worsen that experience by sending them to the wrong pages.
For instance, you might have a new product or service for sale and might want to redirect users to that page. While this makes sense on paper, it’s generally not a good idea to do this. Many visitors log in to a website and want to go to a specific area.
Diverting them to a sales page can get very annoying, especially if they log in regularly.
In general, you want to send visitors to pages that show off content that everyone will be interested in. And this is exactly what a home page is built for. But at the very least, ensure that visitors can easily navigate to other areas of the website.
Redirect to Streamline the Website
Redirecting users in WordPress after login has the potential to boost productivity and interest in the site’s content. There are a number of possibilities whether it’s a reward for registering or putting authors directly in front of resources before writing.
It all depends on your ideas of an efficient website.
What plugins do you use to boost the productivity of your content? How often do you assign new user roles to people on your website?