Drupal Answers Asked by LUS on February 6, 2021
I’m unable to find an example of altering the body of the Webform email confirmation according to the value submitted.
I’ve got in my form a select field, I would like to change the body of the email according to the selected value (not only include the value in the body but change completely the message).
I have thought about something like this but not sure if it works (unable to test at the moment, sorry):
if (isset($message['params']['email']['eid']) && $message['params']['email']['eid'] != 1) {
if ($message['params']['submission']->data[1][0] == 'company') {
$message['body'][0] = 'Thank you .. bla bla.
Bla bla bla.
';
}
}
Or is it possible to do in form_alter hook or maybe some module ?
You can use hook_mail_alter to alter the body of the mail:
Something like
/**
* Implements hook_mail_alter().
*/
function YOURMODULENAME_mail_alter(&$message) {
// Check here for your mail key
if ($message['id'] == 'modulename_messagekey') {
$message['body'][] = 'Thank you .. bla bla.
Bla bla bla.
';;
}
}
Check here https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_mail_alter/7.x for more exemples in comments.
Answered by berramou on February 6, 2021
1 Asked on December 17, 2020 by wassim-akermi
2 Asked on December 16, 2020 by user78498
1 Asked on December 15, 2020 by user17021
1 Asked on December 15, 2020 by sathish
1 Asked on December 14, 2020 by rroose
1 Asked on December 13, 2020
1 Asked on December 13, 2020 by amit-sedai
1 Asked on December 10, 2020 by chefnelone
1 Asked on December 9, 2020 by nitvirus
2 Asked on December 7, 2020 by flamesquirrel
1 Asked on December 5, 2020 by druvision
1 Asked on December 5, 2020 by joachim
1 Asked on December 5, 2020 by sdfff
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP