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 Posts

Fade a Divi Image Module Edge into the Background

Want to create a stylish fade effect on your Divi image module—where one side fades smoothly into the background? With a bit of CSS, you can make any edge (or corner) of the image fade out: top, bottom, left, right, or even diagonally.Fade a Divi Image Module Edge...

Hide the Header and Footer in the Hello Elementor Theme

Removing the default header and footer from your Hello Elementor theme allows for a streamlined and distraction-free website design. This is especially useful when creating unique landing pages, full-width layouts, or custom headers and footers with a page builder. In...

Setting up the Divi Password Box Module

Setting up password protection on a page can help you control access to sensitive or private content in WordPress, allowing only authorized visitors to view certain sections. With the Divi Password Box module, you can replace the plain Divi password form with a fully...

Open Divi Social Media Icons in a New Tab

Ensuring your website's social media icons open in a new browser tab creates a seamless user experience and keeps visitors engaged with your site while allowing them to explore your social media presence. This approach prevents users from navigating away from your...

Set Hover Color for Menu Links in the Divi Menu Module

Customizing the hover color of menu links lets you enhance the user experience and maintain visual consistency with your website’s brand. By setting a specific hover color, you can guide visitors' attention and improve navigation feedback. In this guide we show you...

Random Posts