You are here

function twilio_rules_action_send_sms_to_all_users in Twilio 7

Action: Send an SMS to all users.

1 string reference to 'twilio_rules_action_send_sms_to_all_users'
twilio_rules_action_info in ./twilio.rules.inc
Implements hook_rules_action_info().

File

./twilio.rules.inc, line 204
Rules module integration

Code

function twilio_rules_action_send_sms_to_all_users($message, $media) {

  // Fetch all site users with confirmed numbers.
  $results = db_select('twilio_user', 't')
    ->fields('t')
    ->condition('t.status', TWILIO_USER_CONFIRMED)
    ->execute()
    ->fetchAll();

  // If we have results, iterate through and send the message.
  if (!empty($results)) {
    foreach ($results as $result) {
      twilio_send($result->number, $message, $result->country, $media);
    }
  }
}