Authentication: Login/Logout user redirection

Maintained by Picture of Felipe CarassoFelipe Carasso
Allows sysadmin to force redirection to certain pages upon login or logout.
269 sites
17 fans

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 here

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


Screenshot #0


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

Comments RSS

Show comments
  • Picture of Fabio Uzeltinger
    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/';
  • Picture of HSz HSz
    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 (
    Any assistance welcomed.
  • Picture of Jouni Suorsa
    Fri, Mar 18, 2016, 7:37 PM
    I've created a pull request to address those strict warnings.
  • Picture of Arturo Ruiz Gonzalez
    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
  • Picture of Tom Kleintjens
    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.
  • Picture of Tom Kleintjens
    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;}
  • Picture of Nicolas Ndalpe
    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
  • Picture of Felipe Carasso
    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,
  • Picture of Tore Tuastad
    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?

  • Picture of Felipe Carasso
    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,
  • Picture of James Pearce
    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"

  • Picture of Felipe Carasso
    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,
  • Picture of James Pearce
    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?

  • Picture of Felipe Carasso
    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.
  • Picture of sulagna behera
    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