How to filter a view according to nodes permissions I would like my view to not display nodes to which the current user does not have access to. 

I have implemented hook_permission "access nodes of type mytype"

I have also implemented hook_node_access this way:

function mymodule_node_access( $node, $op, $account)
{

   if ($op == 'create')
    {
     $type = $node;                                                                                                                            
    }

   else
   {

    switch($node-&gt;type)
    {
      case "mytype":
        if ( !user_access("access nodes of type mytype") )
         {return NODE_ACCESS_DENY;}
        break;
    }

   }

 return NODE_ACCESS_IGNORE;
}


I set up the view to displays only nodes of type "mytype". 
When a user who does not have the permission "access nodes of type mytype" clicks on a link in the rows of the view, he gets the page "access denied" which is what I want. 
But I also want the view to not display the nodes of type "mytype" if a user does not have the permission to "access nodes of type mytype".

How do I implement that?

Thanks,

Baba
The correct answer is actually here.


  It seems that a better way to control node access is through hook_node_access_records and hook_node_grants as described here http://drupal.org/node/1260948. This works with views properly.