More than one Autoreply recipient

This documentation page is for Quform version 1 and may not be applicable for Quform 2 click here to visit the documentation for Quform 2.

This guide will show you how to add more than one recipient for the Autoreply email. In the Form Builder make sure you have at least one Email Address type field in the form, and at Form Builder → Settings → Email → Autoreply make sure the Recipient element option is set to the element containing the email address for the first recipient, we will add the other recipients using PHP code. Add the following code to your theme functions.php file (or create a plugin for it):

1
2
34
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function my_autoreply_recipients($mailer, $form, $attachments)
{
    $ids = array('iphorm_1_3', 'iphorm_1_4');    $validator = new iPhorm_Validator_Email();
 
    foreach ($ids as $id) {
        $email = $form->getValue($id);
 
        if ($validator->isValid($email)) {
            $mailer->addAddress($email);
        }
    }
 
    // Hide the recipients from each other (optional)
    $mailer->SingleTo = true;
 
    return $mailer;
}
add_filter('iphorm_pre_send_autoreply_email_1', 'my_autoreply_recipients', 10, 3);
function my_autoreply_recipients($mailer, $form, $attachments)
{
    $ids = array('iphorm_1_3', 'iphorm_1_4');
    $validator = new iPhorm_Validator_Email();

    foreach ($ids as $id) {
        $email = $form->getValue($id);

        if ($validator->isValid($email)) {
            $mailer->addAddress($email);
        }
    }

    // Hide the recipients from each other (optional)
    $mailer->SingleTo = true;

    return $mailer;
}
add_filter('iphorm_pre_send_autoreply_email_1', 'my_autoreply_recipients', 10, 3);
  • On line 3 replace iphorm_1_3 and iphorm_1_4 with the unique IDs of the other Email Address elements that you want to add as recipients. Add or remove values from the array as needed.
  • On line 19 replace the number 1 with the form ID.

See also

Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy