Hi,

I have setup a rule that will notify the "reference user" in a content type when new content is created and the user referenced. This is working great so far. I would like to also notify the user to his/her cell using the regular 0000000@cellcompany.com as a text message.

How can I send both the regular email and the text message?

Note: I have all the users of my site with both emails already collected.

Comments

emilorol’s picture

Hi,

This is a quick note, in case someone is looking for a similar solution:

1. I could not the multiple emails module to do this as the phone numbers are not exposed in a token nor there a way to categorize them like business, personal, cell, etc.

2. My solution was to use the profile and create two fields one to collect the phone number and the other a drop down with the list of the text gateways for multiple providers.

3. From there after updating the profiles of the site users I went ahead and I install the "Profile Token" module that makes every profile field a token.

4. Now back in Rules I just have to add one more action to send an arbitrary email and in the "To" field I added the two tokens like [pager]@[provider] and that is it.

5. Now every time a content type X is added to the site the user been referenced is not only notify by email he/she also gets a text message.

Thank you,
Emil

kevinquillen’s picture

I actually took a different route with Rules support.

In a sense, I added multiple emails as an extended property of the user account. In multiple_email.info.inc (I added to my project), I did the following:

function multiple_email_entity_property_info_alter(&$info) {
  $info['user']['properties']['multiple_emails'] = array(
    'label' => t('Additional emails associated to this user.'),
    'description' => t('Returns a list emails on this user account that were added.'),
    'type' => 'list<text>',
    'getter callback' => 'multiple_email_get_user_multiple_emails',
    'computed' => TRUE,
  );
}

Then, in multiple_email.module, the callback:

/**
 * For a given user, return any additional emails they have listed in their account that are confirmed. This is providing a list to Rules.
 * @param $account
 * @param $language
 * @param $property_name
 * @param $type
 * @param $property_info
 * @return array
 */
function multiple_email_get_user_multiple_emails($account, $language, $property_name, $type, $property_info) {
  $emails = array();
  $query = db_query('SELECT email FROM multiple_email WHERE uid = :uid AND email != :email AND confirmed = :confirmed', array(':uid' => $account->uid, ':email' => $account->mail, ':confirmed' => 1));

  foreach ($query as $record) {
    $emails[] = $record->email;
  }

  return $emails;
}

This returns a list of emails in the account that are non-primary and are marked confirmed. In my Rules action, I would do 'send a system message', to the user:email, and then loop that list variable, and send an email to them as well. This worked extremely well for me. For example, I have a Commerce order: order confirmation email that is sent to a customer on each checkout completion - the same email is also send to the secondary emails in the account.

Edit: Sorry, I did not notice that this was asked against the 6.x version of Multiple Email.

drumm’s picture

Issue summary: View changes

Would be great to see a patch for this. See https://www.drupal.org/patch

The query will need braces, {}, around the table name.

drumm’s picture

Version: 6.x-1.3 » 7.x-1.x-dev
Category: Support request » Feature request
geek-merlin’s picture

Status: Active » Closed (duplicate)

See #2742777: Add entity API integration (where the above is already implemented) and #2742851: Add rules hooks.