By skourak on
Hey all,
I need some help with what should be a simple matter: what is the way to differentiate between a user creating a new node vs editing an existing one? I'm trying to limit a certain content type to one per user, and thus I want to stop the creation of new nodes of that type if one by that user exists already.
I've tried hooking hook_nodeapi() and processing the 'prepare' operation, but as far as I can tell there is no way to distinguish between an add and an edit there. Can someone please shed some light? perhaps I should be looking at a different hook instead?
Thanks in advance for any advice!
Comments
You might want to check out
You might want to check out the Node Limit module which already provide the functionality.
As for you question check
$node->nidwhich should be non zero for existing nodes and zero/unset for new nodes for any operation that occur before the node is saved.Excellent information,
Excellent information, exactly what I needed. Much appreciated!