Hey everyone,

I'm in the middle of creating a node permission module, and have come across a little snag. (outlined here) What I've discovered is that it looks like hook_access() only gets called in a module if that module also defines a new nodetype. Well, my module does not define a nodetype, which is why (I believe) hook_access() isn't getting called.

I want to be able to abort the node creation process before the node creation form ever gets displayed. I know that I could just empty out the form array using hook_form_alter(), but that doesn't seem like a particularly elegant solution to me. Also, hook_nodeapi() doesn't have an 'access' $op.

So, my question is this:

What's the best way to deny node creation for a nodetype that I didn't declare?

Thanks,

Dave

Comments

nevets’s picture

I am guessing that simply setting the permissions is not enough. Under what conditions are you trying to block the form?

davedelong’s picture

Actually, I'm making a new version of this module: http://drupal.org/project/node_limitnumber, which I hadn't heard of before and was just pointed out to me on twitter.

So what I've ended up doing is using the 'presave' $op in hook_nodeapi and then redirecting based on met conditions, along with putting up a drupal_set_message().

Dave

jdwfly’s picture

The Node Limit Number project has been resurrected and many new features have been added. This module now integrates with Rules and the limits are very easy to create. Head over to the Node Limit Number project and grab the latest development copy. The 2.0 release will be out soon.