diff --git a/user/edit_form.php b/user/edit_form.php
index bb614ac..3866b90 100644
--- a/user/edit_form.php
+++ b/user/edit_form.php
@@ -118,6 +118,9 @@ class user_edit_form extends moodleform {
         $mform = $this->_form;
         $userid = $mform->getElementValue('id');
 
+        $systemcontext = context_system::instance();
+        $personalcontext = context_user::instance($userid);
+
         // Trim required name fields.
         foreach (useredit_get_required_name_fields() as $field) {
             $mform->applyFilter($field, 'trim');
@@ -131,19 +134,21 @@ class user_edit_form extends moodleform {
             }
 
             // Print picture.
-            $context = context_user::instance($user->id, MUST_EXIST);
-            $fs = get_file_storage();
-            $hasuploadedpicture = ($fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg'));
-            if (!empty($user->picture) && $hasuploadedpicture) {
-                $imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
-            } else {
-                $imagevalue = get_string('none');
-            }
-            $imageelement = $mform->getElement('currentpicture');
-            $imageelement->setValue($imagevalue);
+            if (has_capability('local/customizations:editownpicture', $systemcontext) || has_capability('moodle/user:editprofile', $personalcontext)) {
+                $context = context_user::instance($user->id, MUST_EXIST);
+                $fs = get_file_storage();
+                $hasuploadedpicture = ($fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.png') || $fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f2.jpg'));
+                if (!empty($user->picture) && $hasuploadedpicture) {
+                    $imagevalue = $OUTPUT->user_picture($user, array('courseid' => SITEID, 'size' => 64));
+                } else {
+                    $imagevalue = get_string('none');
+                }
+                $imageelement = $mform->getElement('currentpicture');
+                $imageelement->setValue($imagevalue);
 
-            if ($mform->elementExists('deletepicture') && !$hasuploadedpicture) {
-                $mform->removeElement('deletepicture');
+                if ($mform->elementExists('deletepicture') && !$hasuploadedpicture) {
+                    $mform->removeElement('deletepicture');
+                }
             }
 
             // Disable fields that are locked by auth plugins.
diff --git a/user/editlib.php b/user/editlib.php
index 7c80aab..7cd05ac 100644
--- a/user/editlib.php
+++ b/user/editlib.php
@@ -261,6 +261,8 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
     if ($user->id > 0) {
         useredit_load_preferences($user, false);
     }
+    $systemcontext = context_system::instance();
+    $personalcontext = context_user::instance($user->id);
 
     $strrequired = get_string('required');
     $stringman = get_string_manager();
@@ -342,7 +344,7 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
     $mform->setType('description_editor', PARAM_CLEANHTML);
     $mform->addHelpButton('description_editor', 'userdescription');
 
-    if (empty($USER->newadminuser)) {
+    if (has_capability('local/customizations:editownpicture', $systemcontext) || has_capability('moodle/user:editprofile', $personalcontext)) {
         $mform->addElement('header', 'moodle_picture', get_string('pictureofuser'));
         $mform->setExpanded('moodle_picture', true);
 
