WordPress User Redirect After Login, Logout to Custom Page

Do you want to set up WordPress user redirect to a custom page after they log in and log out?

By default, WordPress directs users to their dashboard after login and back to the homepage after logout. However, there are instances where you might want to redirect users to specific custom pages based on their login or logout actions.

This article delves into redirecting WordPress users after they log in and log out to custom pages using the ProfilePress plugin.

WordPress User Redirect After Login, Logout to Custom Page

When ProfilePress is installed and activated, the custom pages it creates for login, registration, and password reset are automatically set as WordPress default. Thus, when users visit the following URLs:

  • http://yoursite.com/wp-login.php
  • http://yoursite.com/wp-login.php?action=register
  • https://profilepress.com/wp-login.php?action=lostpassword

They will be redirected to the page containing the custom login, registration, and password reset form created by ProfilePress.

For example, click https://profilepress.com/wp-login.php, and you will be redirected to the website’s custom login page.

To alter these page settings, click the Settings ProfilePress menu and go to the Global Settings section.

User Redirections

To setup WordPress user redirect to a custom page or URL after they log in and log out, select the pages or enter the URL in Redirection section and save.

Note: The URL entered into the custom URL field precedes a selected page.

WordPress Login/Logout Redirect to Currently Viewed Page

This will log the user in/out and redirect them to the page they were viewing when they logged in/out.

WordPress Login Redirect to Previous/Referrer Page

This will log the user in and redirect them to the page they were viewing that referred them to the login page.

WordPress Login Redirect Based on Membership Level

To set up rules that specify where to redirect users after they login based on the membership plan or membership level they are subscribed to, follow the guide below.

Go to ProfilePress  >> Settings >> Login Redirect and scroll to the “Login Redirect Based on Membership Plan” section.

At the bottom right corner, select a membership plan for which you want to set up a login redirect and click the “Add Rule” button.

Finally, enter the URL path or slug to redirect to.

WordPress login redirect based on membership plan

WordPress User Redirect After Login Based on User Role

Go to ProfilePress  >> Settings >> Login Redirect and scroll to the “Login Redirect Based on User Role” section.

At the bottom right corner, select a user role you want to set up a login redirect for and click the “Add Rule” button.

Finally, enter the URL path or slug to redirect to.

WordPress login redirect by user role

Other Registration & Login User Redirections

You can also set custom redirects per login and registration shortcodes via the redirect attribute.

For example, a custom login page with the shortcode below will redirect users to the URL https://xyz.com/welcome after they are logged in.

[profilepress-login id="2" redirect="https://xyz.com/welcome"]

Similarly, a registration page with the shortcode below will log users in and redirect them to https://xyz.com/welcome after successfully creating an account.

[profilepress-registration id="1" redirect="https://xyz.com/welcome"]

If you don’t want users to be logged in before the redirect happens, change “redirect” to “no-login-redirect” like so:

[profilepress-registration no-login-redirect="https://xyz.com/welcome"]

How about if you wish to redirect unregistered or non-logged-in users to your website login page when they try to access a post or page; use the following shortcode on the said post or page.

[pp-redirect-non-logged-in-users]

If you want them redirected to a custom URL, use the shortcode like so:

[pp-redirect-non-logged-in-users url="http://yourwebsite.com/custom-url-slug"]

To redirect only logged-in users to a custom URL, use the following shortcode:

[pp-redirect-logged-in-users url="http://yourwebsite.com/custom-url-slug"]

Remember, no redirection will occur if the user isn’t logged in. And omitting the url attribute will cause the user to be redirected to the login page.

Set up WordPress User Redirect After Login, Logout Today

Redirecting WordPress users after they log in and log out to custom pages provides a powerful tool for enhancing user experience, promoting targeted content, streamlining user flow, and bolstering security.

By utilizing the ProfilePress plugin, you can tailor the redirect paths to suit your specific website needs and objectives. Whether you aim to guide users to relevant content, promote new products, or ensure secure access, custom redirects empower you to create a more user-centric WordPress website.