Drupal show / hide fields in view

SteD picture SteD · Apr 28, 2010 · Viewed 11k times · Source

I would like to show / hide certain fields in my Drupal view accordingly to the user role.

Provided I can only have this view to work with, how can I achieve this programmatically or there's some settings that I am not aware of in Drupal.

P/S: I am aware of the access settings under basic settings in View but that would restrict access to the whole view, not field level.

Answer

Jukebox picture Jukebox · Apr 28, 2010

You can create two identical Displays (within the same view) and override the field settings and access settings in each of them. For example, in the first display show the fields you only want a certain role to see, and set the access control setting to that role. In the second display, remove the unwanted fields and set the access control to the corresponding role.

Start by creating the most restrictive display first and then the least restrictive one.