views:

6

answers:

2

A user might be in role X.

There exist a view, where display A is allowed for role X while display B is restricted.

How do i programmatically check whether a user belonging to role X can access the display or not?

A: 

What you should do, is to check the permission instead of the role using: user_access

googletorp
A: 

Is there a specific reason why you want to do this programmatically? You can set access rules for Views displays in the Views UI:

Edit the view, select the display and look for "Access" in the "Basic settings" block. Click the value (default = "Untrestricted"), click the "Override" button to override the setting for that specific display and choose the settings you need.

marcvangend
I am embedding the view through my custom module. I need to check which display to show to the user by checking his role and the role set in each display.
bibstha