diff --git a/notes/externallib.php b/notes/externallib.php index fab1f22f20b..8f23cae410f 100644 --- a/notes/externallib.php +++ b/notes/externallib.php @@ -690,7 +690,7 @@ class core_notes_external extends external_api { throw new moodle_exception('invaliduserid'); } - if ($course->id != SITEID and !is_enrolled($context, $user, '', true)) { + if ($course->id != SITEID and !can_access_course($course, $user, '', true)) { throw new moodle_exception('notenrolledprofile'); } } diff --git a/user/externallib.php b/user/externallib.php index def4e0d1300..f03b9b858a9 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -1394,7 +1394,7 @@ class core_user_external extends external_api { profile_view($user, $usercontext); } else { // Case like user/view.php. - if (!$currentuser and !is_enrolled($coursecontext, $user->id)) { + if (!$currentuser and !can_access_course($course, $user, '', true)) { throw new moodle_exception('notenrolledprofile'); }