How to hide user profile(edit current password, email, picture, everything) based on role? When user logged in with common shared username and password, I wanted to hide user profile for some of the user based on the given role.

So, I want a feature where user can just logged in and logged out with the given shared user name and password and, I don't want to allow them to change their password or I don't want to allow them to edit in their profile.

I have created separate role for this users.

I came to know that we can hide edit user profile with CSS:

display: none;


Is there any other way to hide user profile based on some roles?
You can set access for fields as FALSE as per user roles.

function YOURMODULE_form_user_profile_form_alter(&amp;$form, &amp;$form_state) {
  global $user;
  if(in_array('your_role_name',$user-&gt;roles)) {
    $form['account']['pass']['#access'] = FALSE;
    // Similarly other fields, but fields can not be required fields on profile.
  }
}