5.x node.module node_access_acquire_grants($node)
6.x node.module node_access_acquire_grants($node)
7.x node.module node_access_acquire_grants($node, $delete = TRUE)

This function will call module invoke to get a list of grants and then write them to the database. It is called at node save, and should be called by modules whenever something other than a node_save causes the permissions on a node to change.

This function is the only function that should write to the node_access table.


$node: The $node to acquire grants for.

Related topics

2 calls to node_access_acquire_grants()
node_access_rebuild in modules/node/node.module
Rebuild the node access database. This is occasionally needed by modules that make system-wide changes to access levels.
node_save in modules/node/node.module
Save a node object into the database.


modules/node/node.module, line 2947
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.


function node_access_acquire_grants($node) {
  $grants = module_invoke_all('node_access_records', $node);
  if (!$grants) {
    $grants[] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0);
  else {
    // retain grants by highest priority
    $grant_by_priority = array();
    foreach ($grants as $g) {
      $grant_by_priority[intval($g['priority'])][] = $g;
    $grants = array_shift($grant_by_priority);

  node_access_write_grants($node, $grants);