node_access check against array of node ids I am in middle of a problem where i have to check node access of current user against an array of node ids.

I have a two content types (A and B) and one contains the reference of other based on a taxonomy. A contains a user role reference fields to allow access to certain roles only. Now i want to show related contents from A on detail page of B. I have used a custom query to fetch all nodes from A somehow related to B. So code is looks like:

$related_nodes = &lt;function_to_get_related_node&gt;;
$result = node_load_multiple($related_nodes);


I have restricted couple of node from A content type to display only certain user roles but $result shows all node from A. Node access not worked.

In my function i have used db_select() with addTag('node_access') but it doesn't seems to be working.

So Basically i want some sort of code to check node_access on array of $related_nodes and filter before it passed to node_load_multiple function.
Could someone help me find a way? Thanks!
How about adding checking if the node has reference of current user while fetching related nodes.

So, 

$related_nodes = &lt;get_related_node&gt;;  

  // Might look Dumb
  function get_related_node($user=NULL) {
    if(is_null($user)) {
      global $user;
    }
    db_select('node','n')
     //Your existing joins
     // One more join for the user reference field, :O
     -&gt;leftJoin('field_data_userreference','ur','ur.entity_id=n.nid')
     // your existing conditions for query.
     // One more condition for the current user as the value on the field.
     -&gt;condition('ur.entity_id',$user-&gt;uid,'=')
    // And the execution continues.
  }


Fields mahcine names to be fixed as per the names provided. It should filter your reference nodes while fetching.