Views check access by PHP I've got 2 roles on my system -uzman and isveren- and several views that need to be restricted to either uzman or isveren. For that purpose, I have been trying to check access control with PHP. I can't use role based access check because then administrator would see all because he has access to all views. Anyway, I am using 

&lt;?php
if (in_array("uzman", $account-&gt;roles)) {
return TRUE;
}
?&gt;


which works, but I see many undefined offset:4 messages in dblog (4 is uzman's rid). What is the correct way to check access with PHP in Views module?
The correct way is to create a custom module and implement hook_permission() to define an appropriate permission:

function hook_permission() {
  return array(
    'administer my module' =&gt; array(
      'title' =&gt; t('Administer my module'),
      'description' =&gt; t('Perform administration tasks for my module.'),
    ),
  );
}


Grant that permission to the roles that require access to it, and then use user_access() to make the access decision:

if (user_access('administer my module', $account)) {
  ...
}


As AyeshK points out in the comments, you don't actually need the second part - Views has n plugin for access based permissions already, which you can configure through the UI. So once you've added the permission and granted it to the relevant role(s), it'll be easy to get what you're looking for.