Redirect to custom page after creating a node with nid as a parameter
Alexzander - December 25, 2008 - 22:57
Hi everybody,
I spent huge amount of time searching net to find best solution. Finally, after understanding node.module, I`ve found out that form_submit return value could be used for redirection.
So, what I want to do is to redirect a user to custom page after node creation with nid as a parameter.
To do it, you should:
1. Create a wrapper submission function, which will call default one (node_form_submit), retrieve nid of created node and redirect to your_custom_page.
<?php
function your_module_redirect_submit($form_id, $form_values)
{
$node_url = node_form_submit($form_id, $form_values);
dpr("Node URL:".$node_url);
return 'your_custom_page/'.str_replace('node/','',$node_url);
}
?>2. Replace default one with yours on form alter for needed_node_type.
<?php
function your_module_form_alter($form_id, &$form)
{
if ($form_id == 'needed_node_type_node_form')
{
unset($form['#submit']['node_form_submit']);
$form['#submit']['your_module_redirect_submit'] = array();
}
}
?>Hope it will help somebody.

You can do it
You can do it with
<?phpfunction yourmodule_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
if ($node->type == 'needed_node_type') {
if ($op == 'insert') {
drupal_goto('your_url/' . $node->nid);
}
}
}
?>
--
CK Ng | myFineJob.com
Read The Fine Manual :~)
You could simply use the Form API's
#redirectproperty.________________________
"Creativity is knowing how to hide your resources" - Albert Einstein.
He needs the nid, I don't
He needs the nid, I don't think you can get it in form_alter hence #redirect will not work.
--
CK Ng | myFineJob.com
Rules module
http://drupal.org/project/rules You can use Tokens in URL