On this page
function contact_personal_form_submit
contact_personal_form_submit($form, &$form_state)
Form submission handler for contact_personal_form().
See also
contact_personal_form_validate()
File
- modules/contact/contact.pages.inc, line 269
- Page callbacks for the Contact module.
Code
function contact_personal_form_submit($form, &$form_state) {
global $user, $language;
$values = $form_state['values'];
$values['sender'] = clone $user;
$values['sender']->name = $values['name'];
$values['sender']->mail = $values['mail'];
// Save the anonymous user information to a cookie for reuse.
if (!$user->uid) {
user_cookie_save(array_intersect_key($values, array_flip(array('name', 'mail'))));
}
// Get the to and from e-mail addresses.
$to = $values['recipient']->mail;
$from = $values['sender']->mail;
// Send the e-mail in the requested user language.
drupal_mail('contact', 'user_mail', $to, user_preferred_language($values['recipient']), $values, $from);
// Send a copy if requested, using current page language.
if ($values['copy']) {
drupal_mail('contact', 'user_copy', $from, $language, $values, $from);
}
flood_register_event('contact', variable_get('contact_threshold_window', 3600));
watchdog('mail', '%sender-name (@sender-from) sent %recipient-name an e-mail.', array('%sender-name' => $values['name'], '@sender-from' => $from, '%recipient-name' => $values['recipient']->name));
// Jump to the contacted user's profile page.
drupal_set_message(t('Your message has been sent.'));
$form_state['redirect'] = user_access('access user profiles') ? 'user/' . $values['recipient']->uid : '';
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!contact!contact.pages.inc/function/contact_personal_form_submit/7.x