Conditionally set recipients based on checkboxes

Home Forums Quform WordPress Conditionally set recipients based on checkboxes

This topic is: resolved
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12953
    mijnonlineid
    Participant

    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,
    Martijn

    Attachments:
    You must be logged in to view attached files.
    #12957
    mijnonlineid
    Participant

    Including Print sreen 2(Settings conditionally set …)

    Attachments:
    You must be logged in to view attached files.
    #12976
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    • This reply was modified 9 years, 5 months ago by Ally.
    • This reply was modified 8 years, 7 months ago by Ally.
    #16692
    podsy
    Participant

    Hello 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!

    #16699
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #16707
    podsy
    Participant

    Ally,

    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!

    #16715
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #16772
    podsy
    Participant

    Great! Seems to be working just fine. Thanks!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy