1

I don't want to display the user picture on the user account page. It is not a field, so I can't simply hide it in display settings. How can I disable it in Drupal 7?

3 Answers 3

6

If you don't want it at all in the user registration you can navigate to : admin/config/people/accounts/settings and uncheck "Enable user pictures" on that page.

If you dont want it only on the user profile page you can add this snippet to template.php in your theme folder

function THEME-NAME_preprocess_page(&$variables){
  if (arg(0)=="user" || arg(0)=="users" ){
    unset ($variables['page']['content']['system_main']['user_picture']);
  }
}
0
0

If you want to get rid of it, go to admin/config/people/accounts/settings and uncheck "Enable user pictures" on that page. Notice this will remove the picture form from registration and profile editing forms, as well as comments, nodes and profiles where this used to show up.

If you want to remove it from the profile page only, just preprocess the profile picture out in template.php:

function THEMENAME_preprocess_user_profile(&$variables) {
  unset($variables['user_profile']['user_picture']);
}
3
  • kudos to @silkAdmin for his answer, which I partially used. Commented Sep 13, 2011 at 15:06
  • apoologies @barrapunto: I accidentally downvoted his answer, but it is the best :(
    – batigolix
    Commented Sep 24, 2014 at 14:30
  • 1
    I don't understand the downvotes on this one. It works exactly as advertised, and is simpler and more to the point than the silkAdmin's answer. Commented Oct 12, 2015 at 5:15
-1

If you want to disable the avatar picture in Drupal 7 for any roles in edit case, then you need to change this:

function hook_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  if ($form_id == "user_profile_form") {   
    if(in_array ( {role_id}, array_keys ( $user->roles ) )) {
      $form ['picture']['#access'] = '0';
    }
}

This is working for my case.

1
  • This removes the picture from the form. The OP asks removing it from display.
    – batigolix
    Commented Sep 24, 2014 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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