And remove the explicit handling of deprecated $USER->capabilities
if ($USER->username != 'guest' and !has_capability('moodle/course:view', $context)) {
if ($COURSE->guest == 1) {
// Temporarily assign them guest role for this context, if it fails later user is asked to enrol
- has_capability('clearcache'); // Must clear cache
- $guestcaps = get_role_context_caps($CFG->guestroleid, $context);
- $USER->capabilities = merge_role_caps($USER->capabilities, $guestcaps);
+ $USER->access = load_temp_role($context, $CFG->guestroleid, $USER->access);
}
}