Merge branch 'MDL-51415-master' of git://github.com/jleyva/moodle
[moodle.git] / user / externallib.php
index 728f23c..dbb384c 100644 (file)
@@ -1419,7 +1419,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');
             }