Forums

Let User Choose Who To Send Email To

LikeStuff 15 Feb, 2012
Joomla: 1.7.3
Chrono Forms: 4.0 RC2.0

How do I set-up my form so that the user can choose who to send an email to? I would like to have a check box so that they can send to all or one person. How can I do that please?

Thanks in advance.
GreyHead 16 Feb, 2012
Hi LikeStuff,

Use a Custom Code action in the On Submit event to check the checkbox value and create a lits of addresses to be used with a Dynamic To address in the Email action. I for get the exact way to set up a list of addresses (it's either a comma separated list or an array) but there are other recent threads about this.

Bob
LikeStuff 16 Feb, 2012
Thanks for the headstart...

I'm missing something and I'm not sure what because the email is been sent to both emails instead of the one I selected. This is what I've done:

I created a checkbox group:
Email_To_LP = Email_To_LP
Email_To_AC = Email_To_AC


Then I add the code below in Events > Custom Code - Before Email(s)
<?php
   $form->data['Email_To_LP'] = 'emailtolp@somedomain.com';
   $form->data['Email_To_AC'] = 'emailtoac@somedomain.com';
?>


Then on Email - #1 > Dynamic To, I add:
Email_To_LP, Email_To_AC


Thanks in advance!!
GreyHead 16 Feb, 2012
Hi LikeStuff,

The Names don't match :-( ChronoForms is sometimes very picky. If you define your options as
Email_To_LP = Email_To_LP
Email_To_AC = Email_To_AC
Then you need to include the space after $form->data['Email_To_LP '] to match it. Try using this instead
Email_To_LP=Email_To_LP
Email_To_AC=Email_To_AC

Bob
LikeStuff 17 Feb, 2012
I'm afraid the spacing isn't the issue. Both codes now match but it's still not working...

Checkbox Group
Email_To_LP=Email_To_LP
Email_To_AC=Email_To_AC


Events > Custom Code - Before Email(s)
<?php
   $form->data['Email_To_LP'] = 'emailtolp@somedomain.com';
   $form->data['Email_To_AC'] = 'emailtoac@somedomain.com';
?>
GreyHead 18 Feb, 2012
Hi LikeStuff,

Please see this post for the syntax to add multiple emails to the Dynamic To box.

Bob
LikeStuff 19 Feb, 2012
Oh boy!! Still getting email sent to both emails. Here's what I have. Not sure what I'm missing.

Checkbox Group
Email_To_LP=Email_To_LP
Email_To_AC=Email_To_AC


Events > On Submit > Custom Code - Before Email(s)
<?php
   $form->data['Email_To_LP'] = 'emailtolp@somedomain.com';
   $form->data['Email_To_AC'] = 'emailtoac@somedomain.com';
?>



Events > On Submit > Email - #1 > Dynamic To
Email_To_LP,Email_To_AC


Thanks!!
GreyHead 22 Feb, 2012
Hi LikeStuff,

Sorry, just got back to this thread. Have you got this sorted now?

Looking at the posts again I'm not sure if you can do the 'all or one' posting in the standard Email action. The standard action can handle comma separated lists or variable names OK. However each entry has to be a single email address and if one of them is empty it will still send a 'blank' address to the mailer.

My Email [GH} action should be able to handle almost any combination of static and dynamic addresses and the dynamic addresses can be comma separated lists or arrays of addresses.

Bob
LikeStuff 22 Feb, 2012
I read this a couple times but not sure what you mean😟

I assume you mean I have to get it done another way in order to get it to work? Is there an example somewhere that works? This was much easier to do in previous versions...

Thank you!!
GreyHead 23 Feb, 2012
Hi LikeStuff,

Then maybe I'm not understanding what you need to do. What I took from the posts is that you want to be able to have a variable number of Dynamic To email addresses?

Bob
LikeStuff 23 Feb, 2012
I think we are talking about the same thing but maybe using different terms.

So just to clarify, I would like the user to be able to choose who they want to send the email to using checkboxes. I would like them to have the option to send to one person or more than one person.

I guess I'm confused 'cause I don't know the process and where to put what.
**Do I need an email event for each of the email addresses?
**What does this mean?

Email [GH] action



Thanks!!
GreyHead 23 Feb, 2012
Hi LikeStuff,

There are several aspects to your addressing request:

a) The user can choose who to send to and there's a sing To address. There are many threads here answering that and you can do it with a Dynamic To address as we've seen in this thread.

b) the user can send to more than one email address - **but always the same number**. You can do this with the standard Email action using any combination of Static and Dynamic To addresses. If you use more than one entry in either the Static or Dynamic To box they need to be a comma separated list and each Dynamic variable should return a single email address.

c) The user can send to more than one email address - and **the number can vary**. This can't be done with the standard Email action without having an error message because one or more of the Dynamic addresses are empty. It can be done with my custom Email [GH] action. This action only has one To Email box but it will accept a comma separated list of email strings and/or input names in curly brackets e.g. user@example.com,{emails_to_use},some_other_email@gmail.com The inputs used there can either be a single email, or a comma separated list of emails, or an array of emails.

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