My site-wide and user contact pages are not redirecting correctly. Despite nearly all my efforts, the visitor is redirected to /, rather than to something I specify. When I peeked in contact.module, it didn't look like most of the other code samples I've seen.

For example, all the tutorials are telling me that a custom form submit function needs to be set in the form, but this module appears to be finding formname_submit implicitly.

Nothing is using form_alter, so most of the other tutorials and faqs I've found don't apply either. I even, just for fun, wrote my own, but it did no good, and I quickly reverted.

In the end, it appears that formname_submit is being overriden. As #redirect overrides _submit, I tried that, but it too was unsuccessful. Finally, by manually adding a ?destination= to the url query on the contact page, it did redirect.

I'd rather not hack a destination into a core module, so any ideas what might override my redirect attempts somewhere between #redirect and ?destination= ? I'd include a code sample... but it's just contact.module, and I haven't touched it!

Comments

adixon’s picture

If you have a custom module called {module_name}, just add this:

function {module_name}_form_alter($form_id, &$form) {
  if ($form['#id'] == 'contact-mail-user') {
    $form['#submit'] = array('{module_name}_contact_submit' => array());
  }
}

function {module_name}_contact_submit($form_id, &$form_values) {
  drupal_set_message('your custom message');
  return 'custompath';
}

If not, you could try the workflow/actions combination, I think that's probably the industrial approach.