diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 5c89fc35bb4..37abbaa816a 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1957,6 +1957,11 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null) { /// If the user is a guest then treat them according to the course policy about guests if (has_capability('moodle/legacy:guest', $COURSE->context, NULL, false)) { + if (has_capability('moodle/site:doanything', $sysctx)) { + // administrators must be able to access any course - even if somebody gives them guest access + return true; + } + switch ($COURSE->guest) { /// Check course policy about guest access case 1: /// Guests always allowed