Community Documentation

Redirect after Form Submission

Last updated June 20, 2009. Created by zzolo on June 20, 2009.
Log in to edit this page.

If you would like to redirect the node form after it has been submitted. It is a simple matter of supplying the #redirect attribute of the form.

<?php
/**
* Implementation of hook_form_alter
*/
function custom_module_form_alter(&$form, $form_state, $form_id) {
  if (
$form_id == 'node_type_form') {
   
// Get the redirect page from some place,
    // like in the URL, Referring URL, or DB
   
$redirect = check_plain($_GET['redirect']);
   
   
// Set form redirect
   
$form['#redirect'] = $redirect;
  }
}
?>

References

Comments

That redirect would work also

That redirect would work also on Delete button, so i think it's not 100% correct.

In a healthy body - healthy mind

About this page

Drupal version
Drupal 6.x
Audience
Programmers
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here