Redirect after Form Submission

Last modified: June 20, 2009 - 21:17

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

 
 

Drupal is a registered trademark of Dries Buytaert.