I am trying to edit users's profile page in Drupal 7. I have an image upload button there, but it remove (hide) after click on upload button .

But If i login with admin its working fine, means image upload section is not hiding on upload click.

Any suggestions ?



Put the following code in a custom module, this module will act on all users but admin (user 1), this will work after user saves/updates his account. inside function there are two sentences begining with $form, first will hide user picture field, second will disable it. use only one. code:

// implementes hook_form_alter
function YOURMODULE_form_alter(&$form, &$form_state, $form_id) {
global $user;
$uuid = $user->uid;
/*  check that user is NOT admin (No1) */
if ($uuid !='1') {
if ($form_id == 'user_profile_form') {
if (!empty($user->user_picture) {
    // Prevent editing a field 
    // hiding the field entirely on the edit form.
    $form['field_user_picture']['#access'] = FALSE;

    // disable update field on the edit form.
    $form['field_user_picture']['#disabled'] = TRUE;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.