Redirect users to specific page after login

Overview

Administrators may want to redirect users to a preset page, such as the Dashboard, after they register or log in. This is an issue due to how the returnURL query string works for the login object. It is intended to redirect users to whichever page they accessed the login page from, but this overrides the setting "Redirect after login," preventing administrators from selecting which page to redirect users to after registration or login.

Procedure

To resolve this issue, add a script to all pages on the administrator's site in order to strip the return URL.

  1. Navigate to Page Output.
    • In DNN 8: Admin > Site Settings > Advanced Settings > Page Output
    • In DNN 9: Settings > Site Settings > SIte Behavior > Default Pages > Page Output
  2. Add the following script to the Portal Header:

    window.onload = function(){
      var loginLink = document.getElementById("dnn_dnnLogin_enhancedLoginLink");
      loginLink.href = loginLink.href.split("?")[0];
    }

The user should now be directed to the page specified in the "Redirect after login" setting, rather than whichever page they logged in from. Validate this by logging in from a different page than the one specified.

 

Content author: Manuel Gonzalez

Comments

1 comment

  • Avatar
    Alexander Lunin

    It does not work in most of the actual versions. Will be fixed in 9.3.0 DNN-8562

    0
    Comment actions Permalink

Please sign in to leave a comment.