Hi,
How do i redirect to node page after submitting the email form.
Need help.

With regards,
B.Sakthi

Comments

john.oltman’s picture

You would have to do that in a hook_form_alter.

sakthiprogrammer’s picture

Hi,

I am new to drupal customization.
Please can you give example.

with regards,
B.Sakthi

john.oltman’s picture

john.oltman’s picture

Status: Active » Closed (works as designed)

More info, add this to a module and then clear cache:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'forward_form') {
     $form['#submit'][] = 'my_submit_handler';
  }
}

function my_submit_handler(&$form, &$form_state) {
  $form_state['redirect'] = $_GET['path'];
}
sakthiprogrammer’s picture

Priority: Critical » Major
Status: Closed (works as designed) » Active

hi,

I wrote this code as separate custom module.
I enabled this custom module and cleared the caches.
But it did not redirect to node page.

With Regards,
B.Sakthi

john.oltman’s picture

Where did it redirect to? Was the submit handler even reached? You may have to put watchdog calls into the submit handler to see what's in the $_GET variable and $form_state variable. You need to do a little debugging.

watchdog('my_module', '

'.print_r($form_state,1).'

');

Then go look at the Drupal log messages.

john.oltman’s picture

Status: Active » Closed (cannot reproduce)