I have added some extra fields in User entity like address, twitter account e.t.c. The requirement is that each user should be able to choose whether his profile will be completely public to other users or some fields should be hidden. The user does not get to choose which ones are hidden or not, he only chooses via a select menu (term reference) what his profile view should be: "Complete" (all fields visible), "Partial" (some predefined fields are hidden) or "Basic Info" (only name and pic).

My question is, what is the best practice to implement the three different profile views according to the user choice? My thoughts so far:

  1. via the respective template using if statements to display or not some fields
  2. via custom display modes, but I don't know how to delegate to another mode conditionally when view_mode is already set to "full"

Any other suggestions are welcome. Thanks in advance.

2 Answers 2


I would suggest that following best practices this should definitely not be accomplished by modifying template files. If you change your theme for example, this functionality should not be effected.

A custom module would be a better place to accomplish this using hook_user_view() http://api.drupal.org/api/drupal/modules!user!user.api.php/function/hook_user_view/7 and modify $account->content to drop the fields that should not be displayed.


I would suggest using the Panels module (http://drupal.org/project/panels). Then you can override the default user profile view with whatever content you want :).

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.