Change where the Divi Login Module Redirects To

Written by Dan Mossop

Divi Includes a Login Module, which lets you add a login box to any page / Divi Builder layout. If you need to control where the user ends up after login in, here are some options:

Redirecting Back to the Current Page

The Divi Login Module includes a built-in option for redirecting the user back to the current page. To use it, enable the option at:

Login Settings > Content > Redirect > Redirect To The Current Page

Redirecting to the Dashboard / User Profile

The default behavior of the Divi Login Module is to redirect the user to either the dashboard or their user profile, depending on the Role set in their profile. To use this behavior, ensure that the option for redirecting the user back to the current page is disabled. You can disable the option (the default) at:

Login Settings > Content > Redirect > Redirect To The Current Page

The option will redirect users as follows:

  • Subscriber – User profile page
  • Contributor – Dashboard
  • Author – Dashboard
  • Editor – Dashboard
  • Admin – Dashboard

Redirect to a Custom URL with Divi Booster

Divi Booster adds an option to redirect the user to a custom page upon login. You can activate it by setting:

Login Settings > Content > Redirect > Redirect To The Current Page = No

Then adding your custom URL at:

Login Settings > Content > Redirect > Custom Redirect URL

After saving the login module settings, your users should be redirected to the custom URL upon login.

This option is available in Divi Booster 3.9.9 upwards.

Redirect to a Custom URL with PHP

You can redirect your login modules to a custom page on log in using this PHP code:

add_filter('et_pb_login_shortcode_output', 'dbc_set_custom_login_redirect');

function dbc_set_custom_login_redirect($output) {
    if (is_user_logged_in()) { return $output; }
    $redirect_to = 'https://localhost/welcome-page';
    $output = preg_replace('/<input type="hidden" name="redirect_to"[^>]*>/s', '', $output);
    $output = str_replace('</form>', '<input type="hidden" name="redirect_to" value="'.esc_attr($redirect_to).'"/></form>', $output);
    return $output;
}

Simply replace 'https://localhost/welcome-page' in the code above with the URL you'd like to redirect to.

Check out Divi Booster

Divi Booster upgrades Divi with hundreds of new features to help you build awesome sites with ease. One of the powerful features included is the ability to redirect users logging in through the Divi Login Module to any URL you choose. Customize your users' post-login experience effortlessly.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

9 Comments

  1. Hi. I use the login module on product template on a B2B site, clients must login in to see prices.
    I would like the module not to redirect at all after login, I want the client to remain on that product page. Is this possible?

    Reply
    • Hi Johan,

      You should be able to achieve that by enabling the following setting in the login module settings:

      Login Settings > Content > Redirect > Redirect To The Current Page

      It returns the user to the current page, meaning they should end up back on the same page they started, i.e. your product page.

      If that doesn't work for you for any reason, let me know. Thanks!

      Reply
      • Sorry, but that does not work. Thanks anyway. Btw, ET support said the same thing.
        Will search all added code to this site, there is something that is over-riding things.

        Reply
        • Hey Johan, sorry that didn't do it. If you are able to share a link to the page with the login I'll be happy to take a look and see if I can spot anything that might be causing it. If you haven't already, it might be worth also clearing any caches in use on the site in case an old version of the page / login module is being displayed…

          Reply
  2. Hi Dan thank you for this guide, for some reason the php code you gave doesnt work anymore?

    Reply
    • Hey Steve, sorry it hasn't been working for you. I've just checked on my test site and the code still seems to be working correctly there (with the latest Divi). Is there any chance you're able to share a link to the page you're working on so that I can take a look at what's going on? Thanks!

      Reply
  3. Hello!
    Is a way to redirect to any specific page (I mean, not to the currente page, neither to the dashboard).
    Thanks.

    Reply
    • Hey René, I've just added a section on how to redirect to a specific page using PHP. I'm also adding an option to set a custom redirect URL to the login module in the next version of Divi Booster (v3.9.9). I should be able to release that update in the next few days and will update the post with details when it's available. I hope that helps! Dan

      Reply
      • Hey René, I've now released the update and have added a section on the feature to the post above. Thanks!

        Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

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

We may earn a commission when you visit links on our website.

Latest From Divi Booster

How to Add the Post Status in Divi's Dynamic Content

Divi's Dynamic Content feature is great for enhancing your post/page templates with post-specific information. While Divi includes an option to show information such as the Post Created Date using Dynamic Content, there is no equivalent option for the Post Status....

Fix Divi Text Module "Regular" Font Weight Not Working

Are you encountering an issue where the font weights in Divi's Text Module don't seem to apply as expected? In particular, you might find that when you set the text module's body text font weight to "Regular", your font is actually assigned a weight of 500 instead of...

Make the Divi Gallery Module Swipeable

The Divi Gallery Module comes with a slider mode that lets you display images in a slider with clickable left/right arrows to scroll through the images. For mobile / touchscreen users, you can improve the user experience by allowing your user to swipe to navigate to...

How to Use Divi Dynamic Content in Woo Modules Product Selector

Divi's Dynamic Content is a powerful feature that lets you populate your Divi modules and theme builder templates with data pulled in various sources, such as custom fields. This allows for efficient organization and maintenance of your sites.Unfortunately, Divi's...

Random Divi Posts