By kcybulski on
I am developing module, in which I need to let users create only one node of this type, if node of this type exists, user should be redirected to edit page of this node. Which hook I should use ?
Best Regards,
Cris
I am developing module, in which I need to let users create only one node of this type, if node of this type exists, user should be redirected to edit page of this node. Which hook I should use ?
Best Regards,
Cris
Comments
hook_nodeapi
Hi,
You could try this module:
http://drupal.org/project/node_limit
I think it may only allow you to restrict the number of nodes that a user/role can create though, rather than limiting the number of nodes of a particular type.
If that's the case then you'll have to use hook_nodeapi (assuming your content type is created by another module, e.g. CCK) to perform a check when $op == validate and use form_set_error() if a node already exists.
John
John Griffin
Atchai Digital
hook_form ?
I am using my module content type. Using hook_form and drupal_redirect_form or drupal_goto give me partial success.
Function
This redirect me when I open 'node/add/production' to '/node/%nid', but when I try $redir = "node/$row->nid/edit"; i get browser error "redirection loop". Any ideas ?
EDIT:
solved problem
Best Regards,
Cris
Redirect Loop
Test to see if drupal is going to /node/add/[content-type]. If so, then try to redirect to /node/[nid]/edit.