More than one Autoreply recipient

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

Still having trouble? Head over to the forums.

Forums