How to Redirect Users after Login & Registration in WordPress

If you own a WordPress site that allows front-end user registration you’re probably looking for an easy way to redirect users after certain actions, like successful login, registration or edit profile, to custom pages and also keep them out of the WordPress dashboard.

pb-custom-user-redirects
Using the new and improved Custom Redirects module from Profile Builder, you can control to a high extend where to redirect users based on their actions.

In this tutorial we’ll go through the different types of custom redirects you can setup.

Types of WordPress User Redirects

The Custom Redirects module supports a couple of redirect types based on certain user actions, as listed below:

  • After Login – redirect users after successful front-end login
  • After Logout – redirect users when logging out
  • After Registration – redirect users after successful front-end registration
  • After Edit Profile – redirect users to a custom page after they edited their front-end user profile
  • Dashboard – redirect users when trying to access the WordPress dashboard
  • After Password Reset – to redirect users after they have successfully changed their password
  • After Email Confirmation – to redirect users after confirming their email address

pb-custom-redirects-types
Now that we listed the type of user actions where we can apply our custom redirects, we’ll look into how to target only certain users, based on redirect filters like user role, username or user ID.

Redirect User based on Username or User ID

One of the most focused types of user redirects is when you need to target only specific usernames, or user IDs.

cr2

Under Custom Redirects -> Individual User Redirects you’ll be able to select which users are redirected to which link after a certain action. You can target a specific user by entering his username or user iD.

Redirect Users based on User Role

Let’s say you have a registration form where users can select their user role (using the User Role Select field) and you want different roles to be taken to different pages after registration.

cr3
Or in case you allow users to sign up for paid accounts using Paid Member Subscriptions with Profile Builder, they will automatically get the user role of the selected subscription plan at registration. Which means users selecting different plans will have different user roles.

pms_pb_register_page
By setting up custom redirects based on user role, you can choose where to redirect users based on which membership plan they applied for at registration.

As you can imagine, the use cases for redirecting users based on user role are countless.

Global WordPress Redirects

These redirects rules are applied globally, when there are no more specific rules defined, like redirects based on username or user role.

cr4

Redirect Users on default WordPress pages

Besides the front-end user redirects listed above, you’ll probably want to keep your users from seeing or accessing the (backend) default WordPress pages like:

  • Login (wp-login.php) – redirect users to the front-end login form created with Profile Builder
  • Register (wp-login.php?action=register) – redirect users to the front-end Profile Builder register form
  • Lost Password (wp-login.php?action=lostpassword) – redirect users to the front-end lost password form
  • Author Archive (http://sitename.com/author/admin) – this has been a common request from Profile Builder users, to be able to redirect people trying to access an author archive to that author profile page, basically the single userlisting template.

cr5

The new Custom Redirects module from Profile Builder has also a list of available tags which can be used for creating dynamic URLs:

  • {{homeurl}} – generates a url of the current website homepage.
  • {{siteurl}} – in WordPress the site url can be different then the home url
  • {{user_id}} – the ID of the user
  • {{user_nicename}} – the URL sanitized version of the username, the user nicename can be safely used in URLs since it can’t contain special characters or spaces.
  • {{http_referer}} – the URL of the previously visited page

Custom Redirects Priority

Which redirect happens depends on the following priority:

  1. Individual User Redirects
  2. User Role based Redirects
  3. Global Redirects
  4. Individual redirects defined in shortcodes or in the Multiple Registration and Edit Profile form settings. (redirect_priority=”top” parameter can be added in any shortcode, then that shortcode redirect will have priority over all other redirects)

Note: If you’re an existing Profile Builder user, by upgrading your old custom redirects settings will be ported over.

This sums up all the user redirect types which can be set using the Custom Redirects module from Profile Builder Pro.

Which type of redirects do you use more often? Let us know in the comments section below.

Subscribe to get early access

to new plugins, discounts and brief updates about what's new with Cozmoslabs!

Leave a Reply

Your email address will not be published. Required fields are marked *