1

I've just got Views Send to work. I have a custom node type, with two email fields. One field contains a~single email address, the second field can contain more email addresses. Using Views Send, I can send mail to either field (even when one field can contain more email addresses).

The question is, can I use Views Send to send an email to both fields at the same time? Now I can only select one field containing emails. Sometimes it is necessary to send the same mail to both fields.

Yves

1 Answer 1

0

I had a look at this interesting module and I am afraid I didn't see a way to do this. I tried Views rewriting, to collect all email addresses from first and second email field into a third one. Standard Views presented the new dynamic field fine... But, this is not supported by the Views Send module. It seems like it would need the data available in the database, and not dynamically generated.

If you want to have that working in an easy way, you could try adding a Computed Field to your content-type. This computed field would then store all the emails from your first and second field. And this concatenated string would be available to Views Send.

Would that be a way out for you? If so, here is an 'draft' version for the code to put in the "Computed Code (PHP)" textarea:

$field_main = field_get_items($entity_type, $entity, "field_main");
$field_additionals = field_get_items($entity_type, $entity, "field_additional");

if(isset($field_main[0])) {
  $emails[] = trim($field_main[0]["value"]);
}

foreach($field_additionals as $field_additional) {
  if(trim($field_additional['value']) !== '') {
    $emails[] = trim($field_additional['value']);
  }
}

$entity_field[0]["value"] = implode(', ', $emails);

Voila! Your computed field is readily available in your Views and Views Send containing all the emails from both fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.