0

short question. I'm using node registration module. Can i use hook_form_alter to redirect to some custom page after form submit?

1
  • Please outline the things you have tried already and post some code. Commented Sep 10, 2015 at 11:47

1 Answer 1

2

To redirect user to a particular page after the form is submitted you can use $form_state['redirect']

eg:

//Implementation of hook_form_alter()
function mymodule_form_alter(&$form, &$form_state, $form_id)
{
    switch($form_id) {
        case 'form_id_of_the_form_to_alter':
            $form['#submit'][] = 'custommade_custom_submit';
    }
}
//Custom submit handler
function custommade_custom_submit($form, &$form_state) {
    $form_state['rebuild'] = TRUE;
    $form_state['redirect'] = 'whatever/link/to/redirect';
}

Hope this helps.

1
  • Ok, I'll check this out later and will let You know if it works. Thanks
    – user51851
    Commented Sep 10, 2015 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.