View Categories

How to Redirect Users After Login in WordPress?

Learn how to automatically redirect users to specific pages after they log in to your WordPress site using the User Registration & Membership plugin. This guide covers both free and premium features with step-by-step instructions.

Prerequisites: User Registration & Membership plugin installed and activated.
✅ Admin access to your WordPress site

Important: The User can log in through the Login and My Account page, which contains login forms. So, you need to add the redirection on those pages or any other pages with login form.

Method 1: Using Login Form Shortcode #

The login form shortcode is the most flexible method for adding redirects. You can use it in posts, pages, widgets, or any area that supports shortcodes.

Shortcode Syntax #

For the Login Page

[user_registration_login redirect_url="YOUR_REDIRECT_URL"]

For My Account Page

[user_registration_my_account redirect_url="YOUR_REDIRECT_URL"]

Step-by-Step Implementation #

  1. Navigate to your desired page or post where you’ve the login form.
  2. Add the shortcode in the content editor.
  3. Replace the URL with your target destination.
  4. Save and publish the page.
Add Redirect URL in Shortcode

Shortcode Examples

[user_registration_login redirect_url="https://www.google.com"]
Redirect User to Specific Page After Login

Method 2: Using Login Form Block #

The Gutenberg block method provides a visual interface for setting up login redirects, making it easier for non-technical users.

Adding the Login Block #

  1. Open the page/post where you want to add the login form.
  2. Click the (+) button to add a new block.
  3. Search for the “Login Form” block.
  4. Add the block to your content.
Login Form Block

The block shows “You are already logged in. Log out?” because the user is viewing it and is already authenticated.

Configuring Login Form Block Settings #

  1. Select the Login block you just added.
    It’ll open the block settings panel in the right sidebar.
Login Form Settings
  • Redirect URL: You can specify where users should be redirected after successful login from here. So, enter your target URL.
  • Logout URL: Set the place where users are redirected after logging out.
  • User State: Specifies how the block will be displayed based on the user’s login status:
    • Logged In: Might show account info or a logout option.
    • Logged Out: Shows the login form.

Save the page after you complete the configuration.

Test WordPress Redirection After Login #

Based on the configuration, you can test the redirection. In our case, we have configured the login block as follows:

Login Block Redirection Example

Let’s test the redirection now:

Redirection Example for Login Block

Method 3: Using My Account Block #

The My Account Block by User Registration & Membership plugin provides comprehensive account management features, including login and logout redirection functionality.

Adding the My Account Block #

  1. On your My Account page, navigate to the Block inserter and click on it.
  2. Search for the “My Account” block and insert it.
Add My Account Block

Configuring Login Redirect Settings for My Account Block #

  1. Select the My Account block, and it opens the block settings panel.
  2. In the block settings, you’ll find:
  • Redirect URL: Enter where users should go after login.
  • Logout URL: Enter the URL where you want to redirect the user after they log out.
  • User State: From here, you can preview the page in either Logged Out or Logged In State.
My Account Block Settings

Click “Save” to update your My Account page settings.

Similar to the above section, you can also perform the test for this configuration.

Advanced: Role Based Redirection Pro #

With User Registration & Membership Pro, you can set up sophisticated redirect rules based on user roles, creating personalized experiences for different user types.

Prerequisites:User Registration & Membership's premium version installed and activated. 

Navigate to User Registration & Membership > Settings > Misc. Now, click on the Role based Redirection tab and enable the redirection.

Click on the Save Changes.

Redirection Type

The plugin provides two settings for redirection:

  • Redirection After Login: From here, you can configure the redirection to users after they log in to your site.
  • Redirection After Logout: From here, you can configure the redirection for users after they log out of your site.

Redirection After Login #

To set up redirection, click on the settings icon for Redirection After Login.

Now, you can choose where to redirect user based on their role. Role-based redirects automatically detect a user’s role upon login and redirect them to appropriate pages. Click on the dropdown menu for each role to select the page accordingly.

Here are some examples of settings for redirection:

  • Administrators → Admin Dashboard
  • Editors → My Account Page
  • Authors → Publishing Dashboard
  • Contributors → Shop or Account Page
  • Subscribers → Content Library

Save the changes after you complete setting up the pages for redirection.

Additional Resources

Powered by BetterDocs

Scroll to top