Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal how to redirect node form after form submission

On Drupal 7 when I post a node I redirect to the specific node created.

I'm searching to redirect to the main admin page when I post correctly the node.

I've tried to put this on template.php:

function node_submit($form, &$form_state) {
  $form_state['redirect'] = 'admin';
}

But there was an error on submit:

Fatal error: Cannot redeclare node_submit() (previously declared in /var/www/XXX/modules/node/node.module:1004) in /var/www/XXX/sites/all/themes/XXX/template.php on line xx

like image 912
rocanroldani Avatar asked Nov 30 '22 14:11

rocanroldani


1 Answers

If all you want to do is change where a user redirects to after they submit an add node form, from a specific link, there is a much easier way.

Just make your link look like this:

/node/add/[CONTENT-TYPE]?destination=[URL-REDIRECT]

Here is an example that I got working:

/node/add/ic-competencies-toolkit-codes?destination=admin/survey-codes
like image 136
Chris Roane Avatar answered Dec 10 '22 22:12

Chris Roane