New operation in hook_access()

430 views Asked by At

Is it possible to define a new operation for a node access?

As I know, the operations for a node that are used in hook_access() are:

  • create

  • delete

  • update

  • view

I have a custom content type for which I need another operation, such as "suggest."

1

There are 1 answers

0
gpilotino On

short answer is NO as node_access() who is responsible to call hook_access() does a check on the $op parameter

if (!$node || !in_array($op, array('view', 'update', 'delete', 'create'), TRUE)) { return FALSE; }

you can attach some extra info to the node object in your suggest() function - hopefully called before node_access() - then check these extra informations in your hook_access() and return TRUE/FALSE according.

another option consists in hardcode permission checks into the suggest() action itself without messing around with hook_access.