function uc_roles_action_user_email in Ubercart 6.2
Same name and namespace in other branches
- 7.3 uc_roles/uc_roles.rules.inc \uc_roles_action_user_email()
Sends an email with order and role replacement tokens.
The recipients, subject, and message fields take order token replacements.
See also
uc_roles_action_user_email_form()
1 string reference to 'uc_roles_action_user_email'
- uc_roles_ca_action in uc_roles/
uc_roles.ca.inc - Implements hook_ca_action().
File
- uc_roles/
uc_roles.ca.inc, line 341 - This file contains the Conditional Actions hooks and functions necessary to make the roles-related entity, conditions, events, and actions work.
Code
function uc_roles_action_user_email($account, $role_expiration, $settings) {
// Token replacements for the subject and body
$settings['replacements'] = array(
'global' => NULL,
'user' => $account,
'uc_roles' => $role_expiration,
);
// Replace tokens and parse recipients.
$recipients = array();
$addresses = token_replace_multiple($settings['addresses'], $settings['replacements']);
foreach (explode("\n", $addresses) as $address) {
$address = trim($address);
// Remove blank lines
if (!empty($address)) {
$recipients[] = $address;
}
}
// Send to each recipient.
foreach ($recipients as $email) {
$sent = drupal_mail('uc_order', 'action-mail', $email, uc_store_mail_recipient_language($email), $settings, $settings['from']);
if (!$sent['result']) {
watchdog('ca', 'Attempt to e-mail @email concerning role notification failed.', array(
'@email' => $email,
), WATCHDOG_ERROR);
}
}
}