node_access_example_node_grants

  1. drupal
    1. 4.7
    2. 5
    3. 6 node_access_example.module
    4. 7 node_access_example.module
Versions
4.7 – 7 node_access_example_node_grants($account, $op)

Implementation of hook_node_grants().

Since we are restricting access based on a permission, we need to check that permission and return the appropriate result.

Code

developer/examples/node_access_example.module, line 54

<?php
function node_access_example_node_grants($account, $op) {
  $grants = array();
  if (user_access('access content', $account)) {
    $grants[] = 0;
  }
  if (user_access('access private content', $account)) {
    $grants[] = 1;
  }
  return array('example' => $grants);
}
?>