Login/Logout user redirection

Authentication ::: auth_loginlogoutredir
Maintained by Felipe Carasso
Allows sysadmin to force redirection to certain pages upon login or logout.
Latest release:
241 sites
17 fans
Current versions available: 1

Use this plugin to force Moodle to redirect a user to specific pages.

Note that login redirection will only work if the target URL contains the "Moodle root" URL. I.e. "{$CFG->wwwroot}/something"

Logout redirection should work to any URL.

Be sure to read and follow the install instructions herehttps://raw.githubusercontent.com/hrimhari/moodle-auth_loginlogoutredir/master/INSTALL

There are manual steps that require access to your Moodle's config.php file.


Screenshot #0


Felipe Carasso (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Tue, Jan 26, 2016, 4:20 AM
    in moodle 2.9.2 not work to redirect to frontpage
    i hack
    moodle\login\lib.php line 308

    if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') {
    // $urltogo = $CFG->wwwroot.'/my/';

    comment line $urltogo = $CFG->wwwroot.'/my/';
  • Wed, Mar 9, 2016, 8:30 AM
    This plugin seems to work on Moodle 3.0.
    The only nagging issue is that it generates a lot of strict warnings.
    Opened issue in github repo (https://github.com/hrimhari/moodle-auth_loginlogoutredir/issues/3).
    Any assistance welcomed.
  • Fri, Mar 18, 2016, 7:37 PM
    I've created a pull request to address those strict warnings.
  • Mon, Apr 4, 2016, 6:19 PM
    Its works in Moodle 2.6, in plugin folder, change de version required to version of the moodle 2.6, and works :D
  • Wed, May 18, 2016, 9:38 PM
    This works fine on 2.9, thank you. Would it perhaps be possible to include an additional parameter to redirect guests-logins to a different url then logged in users? I'm not sure if this is at all possible, but it would be a welcome addition.
  • Wed, May 18, 2016, 10:59 PM
    Adding this to line 18 in auth.php and of course adding the variable $CFG->loginguestredir to the config file fixed it for guest access.
    if ($username == "guest" && $password == "guest") {$urltogo = $CFG->loginguestredir;}
  • Mon, Jul 25, 2016, 2:52 PM
    Hi Felipe,
    Thank you for your plugin. I was just wondering if it would be difficult to add a different link for first time login?

    - First time login = redirect to complete profile page
    - Subsequent login = redirect to course list

    Hope to hear from you soon

    Thank you
  • Tue, Jul 26, 2016, 12:42 AM
    Hi Nicolas,

    I can imagine how to do it, but it's unlikely that I'd do it myself. I'd look into the users table to check for a first login hint and use different url variables accordingly.

    Best regards,
  • Mon, Dec 19, 2016, 5:45 PM
    Hi Hav a problem where i get Abstract user_login() method must be overridden. if I login with wrong username.
    Some research led me to this article:
    wher e it points to youre plugin, is this somthing you are aware of?

  • Mon, Dec 19, 2016, 11:33 PM
    Hi Tore,

    Would you please open a new issue in github? I'll look into it as soon as possible.

    Thank you,
  • Tue, Jan 17, 2017, 8:08 AM
    Excuse my ignorance, but where in the config.php file do I add these entries?

    $CFG->loginredir = "{$CFG->wwwroot}/plus/some/different/path"
    $CFG->logoutredir = "Any URL you want"

  • Tue, Jan 17, 2017, 9:34 AM
    Hi James,

    Any place between the first line where a $CFG-> appears and the end of the PHP code (before the '>' in the end) should be fine.

    Best regards,
  • Tue, Jan 17, 2017, 11:28 AM
    Thanks Felipe,

    Anywhere I paste that code gives a "Parse error" when I load the page. Any further advice?

  • Tue, Jan 17, 2017, 1:42 PM
    Yes, watch out for "smart quotes". If you use the wrong quotes, you'll get a parse error.
  • Thu, Mar 22, 2018, 6:05 PM
    I tried installing this plugin. I added the following code in the config.php
    $CFG->loginredir = "{$CFG->wwwroot}/admin/purgecaches.php";
    $CFG->logoutredir = "{$CFG->wwwroot}";

    It is showing "abstract user login() method must be overridden"
1 2
Please login to post comments