2

Reading the docs I can see that you can conditionally change the recipient of a webform email based on a field value, but that's not quite what I want to do. I want to modify the content of the message based on a form input. For example, based on a webform field like:

Favorite Color: [] Blue [] Yellow [] Red

Upon submission the user should receive totally different email messages saying either:

You probably like the sky...

or

You probably like bananas...

etc. (you get the idea).

Note: it would be clever and would solve this minimalistic example to create the options like

the sky|Blue
bananas|Yellow

and then use their tokens, but that's not an option in this case as it's multiple paragraphs of text I want to be different in the conditional messages.

1
2

This is more of a coding solution but you could implement hook_webform_submission_presave() in a custom module and use that to save the appropriate text to a hidden webform field type, then see if the token for that field will work in the email.

Alternatively, you could implement hook_webform_submission_insert() and send the email programmatically there, which would give you full conditional control of the email recipients and contents.

1

I haven't tried this, but looking to do the same I hope to go with

http://www.drupalcontrib.org/api/drupal/contributions%21webform%21templates%21webform-mail.tpl.php/7

That is, write your own webform-mail-[nid].tpl.php and have php logic there.

0

in drupal 8 it can be set in the handlers parameters

/admin/structure/webform/manage/contact/handlers

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .