Skip to content

Instantly share code, notes, and snippets.

@ostearn
Created August 29, 2017 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ostearn/3482c1cdea015f475945f632f364b7cc to your computer and use it in GitHub Desktop.
Save ostearn/3482c1cdea015f475945f632f364b7cc to your computer and use it in GitHub Desktop.
Moodle login/index.php modification (redirect to last enrolled course)
//this should be added after $SESSION->wantsurl = null; (there are roughly 4 occurances, consider each individually)
if($student_course_arry = enrol_get_users_courses($USER->id, true, Null, 'visible DESC,sortorder DESC'))
{
foreach($student_course_arry as $value)
{
$SESSION->wantsurl = $CFG->httpswwwroot . '/course/view.php?id=' . $value->id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment