18 July 2011

This snippet shows how to redirect form after submitting and saving in Drupal 7. You can also use Rules module for this.

Source code viewer
  1. function HOOK_form_alter(&$form, &$form_state, $form_id) {
  2. if($form_id == 'form_id') {
  3. //add function to complete to at the end of array
  4. $form['actions']['submit']['#submit'][] = 'HOOK_form_id_submit_handler';
  5. }
  6. }
  7. function HOOK_form_id_submit_handler($form, &$form_state) {
  8. //redirect to this path
  9. $form_state['redirect'] = 'some/path/to/redirect/to';
  10. }
Programming Language: PHP