}
//User is not enrolled in the course, wants to access course content
- //as a guest, and course setting allow unlimited guest access
+ //as a guest, and course setting allow unlimited guest access;
+ //do not autologin as guest when $autologinguest is false
//Code cribbed from course/loginas.php
- if (strstr($FULLME,"username=guest") && ($course->guest==1)) {
+ if (strstr($FULLME,"username=guest") and ($course->guest==1) and $autologinguest) {
$realuser = $USER->id;
$realname = fullname($USER, true);
$USER = guest_user();