Drupal: Change Redirect When A Form Is Saved
When a form is saved, a user is navigated to a view page of the last saved node (‘View’ tab). It is necessary to make redirect to some URL.
You need to create a module and add the following code to MODULENAME.module file:
function MODULENAME_form_alter(&$form, &$form_state, $form_id) {
if (‘page’ == $form[‘#node’]->type){
$form[‘#redirect’] = ‘thanks_page';
}
}
This code works before editing form is shown in user’s browser and a standard redirect will be changed in this form. Please keep in mind that this is for page nodes only. However, you can use other conditions.
If you need to use special symbols in a path, please use construction like this:
function MODULENAME_form_alter(&$form, &$form_state, $form_id) {
if (‘page’ == $form[‘#node’]->type){
$form[‘#redirect’] = array(‘flex’, ‘component=pbrowser’, ‘t=1′);
}
}
Otherwise Drupal will change spacial symbols (?, & etc.) to secure symbols.
Useful links:
Redirecting with query string
Used materials: