hook_node_grants() implemented by a custom module is not invoked I am using the following code in a Drupal 7 module.

define('BNA_ACCESS_REALM', 'billetsalget_nodeaccess');

function billetsalget_nodeaccess_node_access_records($node) {
  $producttypes = array('internal_product', 'external_product', 'call_product', 'event_product');
  $grants = array();

  if (in_array($node-&gt;type, $producttypes)) {
    $grants[] = array(
      'realm' =&gt; BNA_ACCESS_REALM,
      'gid' =&gt; $node-&gt;nid,
      'grant_view' =&gt; TRUE,
      'grant_update' =&gt; 0,
      'grant_delete' =&gt; 0,
      'priority' =&gt; 0,
    );
  }

  return !empty($grants) ? $grants : array();
}

function billetsalget_nodeaccess_node_grants($account, $op) {
  dpm($account);
  die(var_dump($account));
}


hook_node_access_records() is working and running as it should, adding data to the database.
As far as I can see hook_node_grants() is never invoked. I have tried with all sorts of stuff in there, but it just looks like it doesn't even run.



It didn't have anything to do with my code. I'm new to Drupal so I didn't know hook_node_grants() don't get invoked when I'm signed in as an administrator.
Newbie mistake from my side :)
It didn't have anything to do with my code. I'm new to Drupal so I didn't know hook_node_grants() don't get invoked when I'm signed in as an administrator. Newbie mistake from my side :)