How to hook into access control of node/add menu handler? Looking at Drupal code, I noticed the following function.

function _node_add_access() {
  $types = node_type_get_types();
  foreach ($types as $type) {
    if (node_hook($type-&gt;type, 'form') &amp;&amp; node_access('create', $type-&gt;type)) {
      return TRUE;
    }
  }
  if (user_access('administer content types')) {
    // There are no content types defined that the user has permission to create,
    // but the user does have the permission to administer the content types, so
    // grant them access to the page anyway.
    return TRUE;
  }
  return FALSE;
}


What is node_hook()? How can I implement this hook for additional access control?
node_hook() is not an hook; it's a helper function Drupal uses to verify a content-type hook exists. In the code you are showing, the function is verifying the module implementing the $type-&gt;type content type implements hook_form().

To alter the access control for a node, you have two options:


Implementing hook_node_access()
Implementing hook_node_grants() and hook_node_access_records()


Implementing hook_node_access() is easier, but that hook is not used in node listings (lists of nodes generated from a select query, such as the default home page at path 'node', an RSS feed, a recent content block, etc.).

Notice that, since _node_add_access() is an access callback, you could change the access callback used by node/add. I suggest not doing it because that would by-pass all the node access control implemented by Drupal.

Reference


Node access right