Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

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.

share|improve this answer

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 :).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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