Thanks for choosing Option B

webmasterancilla 29 Feb, 2016
I want to have some of the text of the email returned to the user of the form depend on the choice they make on a drop down box while filling out the form.
For Example:
Chose option A and the email will end up including - Thanks for choosing Option A!
Chose option B and the email will end up including - Thanks for choosing Option B!
Is there an easy way to do this?

Mike
GreyHead 29 Feb, 2016
HI MIke,

Use a Custom Code action before the Email action with code like this
<?php
switch ( $form->data['select_name'] ) {
  case 'option_a':
  default:
    $form->data['message'] = 'Thanks for choosing Option A!';
    break;
  case 'option_b':
    $form->data['message'] = 'Thanks for choosing Option B!';
    break;
  // . . .
}
?>
Then add {message} in the email template.

Bob
webmasterancilla 29 Feb, 2016
That's especially nice. Can I put HTML and {curly_brackets_data} in the 'message' instead of Thanks for choosing Option A!
GreyHead 29 Feb, 2016
Hi webmasterancilla,

You can add form data using $form->data['input_name'] - the curly brackets won't work inside PHP tags. Please see this FAQ for an example.

You can use HTML but watch the quotes, I generally wrap the whole string in double quotes " " - then use single quotes where they are needed in the HTML

Bob
This topic is locked and no more replies can be posted.