You are here

function messaging_message_bulk_send in Messaging 6.4

Send message to multiple users. For each user it will use the preferred method

Parameters

$users: User id, array of user ids, user account or array of user accounts

$message: Message object to use as template or array with 'subject' and 'body' texts

Return value

array Array with sending result, indexed by user id

File

./messaging.module, line 321

Code

function messaging_message_bulk_send($users, $message, $queue = FALSE) {

  // Convert users to array of user account objects
  $users = is_array($users) ? $users : array(
    $users,
  );
  $users = array_map('messaging_user_object', $users);
  $template = messaging_message_build($message);
  $results = array();
  foreach ($users as $account) {
    $message = clone $template;
    $results[$account->uid] = messaging_message_send_user($account, $message, NULL, $queue);
  }
  return $results;
}