isguest() compatible with roles
This commit is contained in:
+12
-1
@@ -2262,7 +2262,18 @@ function isstudent($courseid, $userid=0) {
|
||||
* @return bool
|
||||
*/
|
||||
function isguest($userid=0) {
|
||||
global $USER;
|
||||
global $USER, $CFG;
|
||||
|
||||
if (!empty($CFG->rolesactive)) {
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
|
||||
if (!$userid) {
|
||||
return has_capability('moodle/legacy:guest', $context);
|
||||
} else {
|
||||
return has_capability('moodle/legacy:guest', $context, $userid);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$userid) {
|
||||
if (empty($USER->username)) {
|
||||
|
||||
Reference in New Issue
Block a user