View Categories

How to Redirect Users After Logout in WordPress?

Learn how to redirect users to specific pages after they log out of 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 logout option is automatically available on pages that contain login forms, including the My Account page. If you’ve created custom pages for your login form, you’ll also need to add the redirection to those pages.

Method 1: Using Shortcode #

Using a shortcode is the most flexible method for adding redirection after logout.

You can add the shortcode to the Login and My Account page, since this is typically where users are redirected after login and where they’ll access the logout option.

Shortcode Syntax #

The basic shortcode for redirection after logout functionality in the User Registration & Membership activated website is as follows:

For Login Page:

[user_registration_login logout_redirect="https://yoursite.com/thank-you-logout/"]

For My Account Page:

[user_registration_my_account logout_redirect="https://yoursite.com/thank-you-logout/"]

Step-by-Step Implementation #

Here’s how you can implement the shortcode:

Step 1: Set Up Redirect Page

First, create or decide on the page where you want users to be redirected after logging out. This could be your homepage, a thank you page, a custom landing page, or any external page.

Step 2: Copy the Page URL for Redirection

Copy the full URL of your redirect page:

Step 3: Add the Shortcode

To add a shortcode block, let’s navigate to the Login page and click the + sign. You can simply search for the Shortcode block and add the block.

Shortcode Block

Paste the shortcode with your redirect URL inside the block and save the page. You can add any URL of your choice for the redirection.

[user_registration_login logout_redirect="sample-page"]
Add Logout Redirection in Login Page

Similarly, you can add the shortcode in the My Account page.

[user_registration_my_account logout_redirect="https://wordpress.org/"]
Add Logout Redirection Shortcode

Save the page to experience the changes.

Step 4: Test the Logout Redirection

  • You can register a new user on your website to test the redirection.
  • Next, log in to the website and click the Logout or Signout link.

For a successful configuration, it should redirect you to the page you have set for redirection.

Redirection Example After Logout

Method 2: Using Login Form Block #

WordPress Block Editor users can utilize the Login Form for logout redirections with a visual interface. This block is offered by the User Registration & Membership plugin.

Adding the Login Block #

  1. Navigate to the page where you want to add the login form.
  2. Click “Add Block” (+).
  3. Search for the Login Form” block and insert the block.
Login Form Block

Configuring Login Form Block Settings #

With the login block selected, look for the block settings panel on the right side of your screen.

Login Block Redirection Example

In the block settings panel, configure:

  • 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.

Similar to Method 1, you can also test the configuration for this method.

Method 3: Using My Account Block #

The My Account Block by User Registration & Membership offers complete account management functionality, including the ability to set logout redirect destinations.

Adding the My Account Block #

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

Configuring Logout Redirect Settings for My Account Block #

Click on the My Account block, and you’ll see the block settings panel on the right:

  • Redirect URL: Enter where users should go after logging into your site.
  • Logout URL: Enter the URL where you want to redirect the user after they log out.
  • User State: It shows the preview of your My Account page in Logged Out or Logged In State.
My Account Block Settings

Click “Save” to update the page settings. Like 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 plugin 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 configure logout redirection based on user roles, click on the settings icon for Redirection After Logout.

You can now define specific logout destinations for each user role on your site. Role-based logout redirects automatically identifies a user’s role when they log out and directs them to the most appropriate page. Use the dropdown menu for each role to select the corresponding destination page.

Here are some strategic examples for logout redirection settings:

  • Administrators → Security Notice Page
  • Editors → Editorial Guidelines Page
  • Authors → Writing Resources Hub
  • Contributors → Submission Thank You Page
  • Subscribers → Membership Renewal Page

Save your configuration once you’ve finished assigning logout destinations for each user role.

Additional Resources

  1. How do you redirect the user to a specific page after login?
  2. User Registration & Membership Pro Guide.

Powered by BetterDocs

Scroll to top