You are here

function pm_send in Privatemsg 6

Submit callback for the privatemsg_new form.

1 string reference to 'pm_send'
privatemsg_new in ./privatemsg.module

File

./privatemsg.module, line 1098
Allows users to send private messages to other users.

Code

function pm_send($form, &$form_state) {
  $status = _privatemsg_send($form_state['validate_built_message']);

  // Load usernames to which the message was sent to.
  $recipient_names = array();
  foreach ($form_state['validate_built_message']['recipients'] as $recipient) {
    $recipient_names[] = theme('username', $recipient);
  }
  if ($status !== FALSE) {
    drupal_set_message(t('A message has been sent to !recipients.', array(
      '!recipients' => implode(', ', $recipient_names),
    )));
  }
  else {
    drupal_set_message(t('An attempt to send a message <em>may have failed</em> when sending to !recipients.', array(
      '!recipients' => implode(', ', $recipient_names),
    )), 'error');
  }
}