I'm looking for a hook to use after a node of a specific content type is created or saved, to perform a redirection to a specific page.
4 Answers
In case of Drupal 6 hook_nodeapi() will help to perform on various actions, basing on the value of the first argument passed to the hook ($op
).
- alter
- delete
- load
- update
In Drupal 7 there is a number of hooks for this.
Form redirect after node save. This blog discusses the usually way of redirecting a form, the problem with node forms, and how to solve them for Drupal 6. I believe it should also work for Drupal 7
If "created" and "saved" mean node has been on database, here some option.
/** * Implements hook_form_NODE_TYPE_node_form_alter() * Add some action to submit button */ function CUSTOM_MODULE_form_NODE_TYPE_node_form_alter(&$form, &$form_state){ $form['actions']['submit']['#submit'][] = 'CUSTOM_MODULE_form_NODE_TYPE_node_form_submit'; } function CUSTOM_MODULE_form_NODE_TYPE_node_form_submit(&$form, &$form_state){ $node = $form_state['node']; // CHECK NODE TYPE AND REDIRECT }
Here similar case which can be done by this option.