Skip to content

Instantly share code, notes, and snippets.

@willianmano
Created May 21, 2018 12:16
Show Gist options
  • Save willianmano/8fd1616322bb33fbb5a097b042fcf5b4 to your computer and use it in GitHub Desktop.
Save willianmano/8fd1616322bb33fbb5a097b042fcf5b4 to your computer and use it in GitHub Desktop.
Moodle redirects after login
<?php
// File located in the DB folder
$observers = array(
array(
'eventname' => '\core\event\user_loggedin',
'callback' => 'yourplugin_dashboard_redirect',
'includefile' => 'yourplugin/localib.php'
)
);
<?php
// File located in the plugin root folder
function yourplugin_dashboard_redirect(){
GLOBAL $CFG;
if(!is_siteadmin()){
redirect($CFG->wwwroot.'/yourplugin/dashboard.php');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment