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

Method 1: Using Built-In Login Redirect Setting in Form Options #

You can easily redirect users to a specific page after login using the built-in setting available in the Login Form options. No custom code is required.

Steps to Set Redirect After Login

  1. Go to User Registration & Membership → Login Form
  2. Click on the Login Form to edit it
  3. Navigate to Form Settings → Advanced
  4. Enable the Enable Custom Redirect option
  5. Under Redirect After Login, choose your preferred option:
    • No Redirection – Users will remain on the default page after login.
    • Internal Page – Redirect users to a specific page from your website.
    • External URL – Redirect users to a custom external link (you need to enter the full URL).
    • Previous Page – Redirect users back to the page they were on before logging out.
    • Role Base Redirection – Redirect users to different pages after login based on their user role. And it is a premium feature.
  6. Click Update Form to save the changes

Users will now be redirected to the selected page or URL after logging out.

    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.

    Method 4: 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

    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. 

    To configure redirect after login based on user roles, follow this in the plugin:

    User Registration & Membership → Login Form → Edit Login Form → Form Settings → Advanced → Enable Custom Redirect → Redirect After Login → Role Based Redirection

    Next, choose the pages where each user role should be redirected, and click Update Form.

    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