diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 40633b7ef08..ef99acc00d7 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -7416,7 +7416,7 @@ function forum_get_posts_by_user($user, array $courses, $musthaveaccess = false, // Check whether the requested user is enrolled or has access to view the course // if they don't we immediately have a problem. - if (!can_access_course($course, $user)) { + if (!can_access_course($course, $user) && !is_enrolled($coursecontext, $user)) { if ($musthaveaccess) { print_error('notenrolled', 'forum'); }