diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 27ef0d3c64d..fa879583469 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2740,6 +2740,10 @@ function require_login($courseorid = NULL, $autologinguest = true, $cm = NULL, $ if ($preventredirect) { throw new require_login_exception('Course is hidden'); } + // We need to override the navigation URL as the course won't have + // been added to the navigation and thus the navigation will mess up + // when trying to find it. + navigation_node::override_active_url(new moodle_url('/')); notice(get_string('coursehidden'), $CFG->wwwroot .'/'); } }