When submitting a message in my site-wide contact form in Drupal 6.x I get the following message along the top of every message:
[Name] sent a message using the contact form at [www.mysite.com/contact]
I would like to remove this message. Looking around, I've found it comes from the contact.module here:
$message['body'][] = t("!name sent a message using the contact form at !form.", array('!name' => $params['name'], '!form' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language))), $language->language);
I've done a bit of research and it seems that I need to create a custom module with a hook_mail_alter() function to edit the contact.module. When it comes to this I get a bit lost. Could anyone kindly take me through the steps to accomplish the task?
Many thanks.
I did something like that recently. Here is a template you can use to get what you need. Most is from the contact module. The code below is from Drupal 7 but should work as is in Drupal 6.
/**
* Implementation of hook_mail_alter().
*/
function modulename_mail_alter(&$message) {
if ($message['id'] == 'contact_page_mail') {
$language = $message['language'];
$params = $message['params'];
$variables = array(
'!form-url' => url($_GET['q'], array('absolute' => TRUE, 'language' => $language)),
'!sender-name' => format_username($params['sender']),
'!sender-url' => $params['sender']->uid ? url('user/' . $params['sender']->uid, array('absolute' => TRUE, 'language' => $language)) : $params['sender']->mail,
);
$message['body'] = array();
$message['body'][] = t("Your custom message with variables", $variables, array('langcode' => $language->language));
$message['body'][] = $params['message']; // Append the user's message/
}
}