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
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']);
}
}
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']);
}
-
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 :( Commented Sep 24, 2014 at 14:30
-
1I 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
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.
-
This removes the picture from the form. The OP asks removing it from display. Commented Sep 24, 2014 at 14:07