diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d6bba110a09..dbd6fcaccee 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2760,7 +2760,11 @@ function require_login($courseorid = NULL, $autologinguest = true, $cm = NULL, $ $access = false; - if (is_viewing($coursecontext, $USER)) { + if (is_role_switched($course->id)) { + // ok, user had to be inside this course before the switch + $access = true; + + } else if (is_viewing($coursecontext, $USER)) { // ok, no need to mess with enrol $access = true;