Home › Forums › Quform WordPress › Conditionally set recipients based on checkboxes
- This topic has 7 replies, 3 voices, and was last updated 8 years, 7 months ago by podsy.
- AuthorPosts
- November 5, 2014 at 1:45 pm #12953mijnonlineidParticipant
Hello,
I have the following question:
I have build a form as showcased within print screen 1 (Example form).
I would like to send the form details to a certain email address based on their choice to receive a brochure from company 1, 2 or 3 (Conditionally set recipients based on form values).
As you can see within print screen 2 (Settings conditionally set …) I don’t get the option to choose this form value (checkboxes).
It will be great if you can help me out with this issue.
Greetings,
MartijnAttachments:
You must be logged in to view attached files.November 5, 2014 at 1:56 pm #12957mijnonlineidParticipantIncluding Print sreen 2(Settings conditionally set …)
Attachments:
You must be logged in to view attached files.November 6, 2014 at 11:28 am #12976AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
September 2, 2015 at 8:00 am #16692podsyParticipantHello there,
I was going to post a new thread with a similar question but this seems like exactly what I was looking for. I’ll start a new thread if that would be better.
Could you please make sure I did this correctly:
I am using checkboxes to choose from 4 locations. Depending on which location or locations are chosen, I would like the form to be sent to the appropriate email. Multiple locations could be chosen.
Here is the code I used but also changed the number 3 to a 4 in the last line since I assumed this corresponds to the number of checkboxes.
function my_conditional_recipients($mailer, $form, $attachments) { $locations = (array) $form->getValue('iphorm_2_247'); if (in_array('Location 1', $locations)) { $mailer->addAddress('location1@email.com''); } if (in_array('Location 2', $locations)) { $mailer->addAddress('location2@email.com''); } if (in_array('Location 3', $locations)) { $mailer->addAddress('location3@email.com''); } if (in_array('Location 4', $locations)) { $mailer->addAddress('location4@email.com'); } // Hide the recipient addresses from each other $mailer->SingleTo = true; return $mailer; } add_filter('iphorm_pre_send_notification_email_2', 'my_conditional_recipients', 10, 4);
Thank you for your help!
September 2, 2015 at 10:26 am #16699AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
September 2, 2015 at 9:56 pm #16707podsyParticipantAlly,
Thank you so much for your reply! Yes I would love for you to take a look. But first, would it be possible to add multiple emails to each checkbox selection?
I would like 2 email addresses per checkbox. Thanks!
September 4, 2015 at 3:36 pm #16715AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
September 8, 2015 at 7:23 am #16772podsyParticipantGreat! Seems to be working just fine. Thanks!
- AuthorPosts
- You must be logged in to reply to this topic.