0

I am using Drupal 7 profile2 module for creating user profile and Organic group module for group managemnet.

I have user status field in user profile, and there are two options(radio button) for visibility of profile field like 1. Visible in Group 2. Invisible.

Visible in Group is selected then any group member can see the user status

Invisible then no one can see the user status field

Now I want to know that is there any way to unset the profile field during viewing. Is any hook calling during user view event ?

I have also the code that checks whether user being viewed and logged in user are member of same group or not

1 Answer 1

1

hook_entity_view can be used all core and most contrib entities and the more specific hook_user_view can be used when the user account is used - this is, however, not the same as the user profile itself.

You should note that this wont effect fields and entities displayed by views.

5
  • @googletrop: I want to unset some of the profile fields: i mean I want solution like unset($profile['fieldname']) is it possible to achieve it Commented Oct 19, 2012 at 11:05
  • @mohit_rocks Yes
    – googletorp
    Commented Oct 19, 2012 at 11:07
  • thanks for your reply, but this way it is not working. I mean field is still displayed Commented Oct 19, 2012 at 11:12
  • @mohit_rocks Did you inspect the variables to see where the field markup is located - you are aware that it's not the field itself but the field content you need to disable. You can also use manage display if you always want to hide the field
    – googletorp
    Commented Oct 19, 2012 at 12:42
  • @googletrop: I don't want to hide the field all the time, actually it depends on the value of radio buttons. Commented Oct 19, 2012 at 12:53

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.