Drupal: Redirect create node form to custom page after save

Normally, we'd set $form['#redirect'] within the hook_form_alter() step if we want to edit the redirect.

But for node forms, the 'Save' and 'Preview' buttons change the behaviour, so we'll need to add our own submit handler and do it within the callback.

/*
* Implements hook_form_alter().
*/
function mod_form_alter(&$form, $form_state) {
$form['buttons']['submit']['#submit'][] = 'mod_form_finish_redirect';
unset($form['buttons']['preview']);
}

/**
* Custom submit handler. Overwrites the form redirection variable.
*/
function mod_form_finish_redirect($form, &$form_state) {
$form_state['redirect'] = '/some/other/path';
}
 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog