O'Reilly logo

Drupal 7 Module Development by Ken Rickard, John Wilkins, Larry Garfield, Matt Butcher, Greg Dunlap, Matt Farina

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using hook_node_access()

Drupal 7 replaces the old hook_access() function with hook_node_access(). This change was one of the many improvements to come from a work session at DrupalCON Szeged in 2008, and credit goes to Larry Garfield (Crell) for implementing these changes.

hook_node_access() allows any module to have a say in how node access is handled. It does not require database storage, or the use of the rest of the Node Access API. Further, it may be applied to any of the four basic CRUD operations.

The hook passes three parameters:

  • $node, the complete node object being acted upon, or a node type string in the case of the Create operation.
  • $op, the operation being performed.
  • $account, the user requesting access to the node for this action. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required