diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php index 67c74e8e580..aaaf81f0f5e 100644 --- a/blocks/online_users/block_online_users.php +++ b/blocks/online_users/block_online_users.php @@ -1,4 +1,4 @@ -prefix}role_assignments + WHERE userid = $puser->id + AND contextid $pcontext + AND hidden = 1"; + + if (!has_capability('moodle/role:viewhiddenassigns', $context) && record_exists_sql($SQL)) { + // can't see this user as the current user has no capability + // and this user has a hidden assignment at this context or higher + continue; + } + $puser->fullname = fullname($puser); $users[$puser->id] = $puser; }