Hi, where is the Switch feature in Chronoforms 8? I need to email to a specific user based on a field on the contact form. I used the switch feature before in v.6
Thanks.
Hi, where is the Switch feature in Chronoforms 8? I need to email to a specific user based on a field on the contact form. I used the switch feature before in v.6
Thanks.
Use a PHP action based on the value of your field. if... {return email1@mail.de;"} etc. You name the PHP action switch_mail, for example.
In the mail action, you use {var:switch_mail} as the recipient.
Or you include the mail action in the event of the PHP action. if... {return email1;"} ... if... {return email2;"} etc. , add an event email1 and here the mail1 action, add an event email2 and here the mail2 action etc...
I think that's how it should work.
Hi, I tried this but with no luck.
Can you be a little more specific.
I tried it in both and then added the variable in the email but just got an error saying "Invalid address: (to):"
I added this PHP code to a PHP Action on the 'Submit' tab :
if (isset($form->data['contact_type'])) { $contact_type = $form->data['contact_type']; // Switch based on contact_type if ($contact_type == 'Maintenance') { $form->data['email_add'] = 'maintenance@studentbeehive.co.uk'; } elseif ($contact_type == 'Contact') { $form->data['email_add'] = 'info@studentbeehive.co.uk'; } else { $form->data['email_add'] = 'default@studentbeehive.co.uk'; // Fallback in case no match } // Return the email for backward compatibility or debugging (optional) return $form->data['email_add']; }
Then added the variable in the email: {var:email_add}
This is my process
switch_mail
) sets the appropriate email address and stores it in the email_add
variable.{var:email_add}
as the recipient email.But does not work.
if you do a PHP code switching like this:
$email = "1@domain.com";
if($this->data("field") == "2"){
$email = "2@domain.com";
}
return $email;
and your PHP action name is php_5 then you can use {var:php_5} as the recipient, but your PHP action should be before the email action