When does hook_node_access get invoked for $op == "create" ? In other words, at what portion of the node creation process is this permission checked? I am not seeing anything in the API does about this.

I have a situation where I need to restrict a subset of users to only be allowed to create/edit content with a particular taxonomy term based on their user profile. I have the $op == "update" and node form logic all worked out, and am not sure what I need to do about $op == "update"



It gets called from _node_add_access(), which is the access callback for the node/add path (see node_menu()):

foreach ($types as $type) {
  if (node_hook($type->type, 'form') && node_access('create', $type->type)) {
    return TRUE;

node_access() has this line in it:

$access = module_invoke_all('node_access', $node, $op, $account);

Which is when hook_node_access() is actually invoked.

To answer your question, it's called before the node add form is ever displayed to a user; obviously if it returns FALSE then access is denied to the form.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.