diff --git a/user/view.php b/user/view.php
index 0c1efa7a8ed..2f9b8e9ba30 100644
--- a/user/view.php
+++ b/user/view.php
@@ -292,9 +292,11 @@ if (!isset($hiddenfields['mycourses'])) {
echo "";
-echo '
';
-echo html_writer::link($CFG->wwwroot.'/user/profile.php?id='.$id, get_string('fullprofile'));
-echo '
';
+if ($currentuser || has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($id)) {
+ echo '';
+ echo html_writer::link($CFG->wwwroot.'/user/profile.php?id='.$id, get_string('fullprofile'));
+ echo '
';
+}
/// TODO Add more useful overview info for teachers here, see below