Change where the Divi Login Module Redirects To

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.

This post may contain referral links which may earn a commission for this site

Divi Booster

Hundreds of new features for Divi
in one easy-to-use plugin

3 Comments

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

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