Customizing the autoreply email content

This guide is for advanced usage, you can modify the autoreply email content inside the form builder at Settings → Email → Autoreply email settings

This guide will outline how to build the autoreply email content at the PHP level, which is useful if you need to display output from from WordPress functions or variables and other complex logic in the email.

Step 1

Get the unique ID of the form, see Finding the form ID.

Step 2

Create a file named autoreply-content.php and enter the email content, in HTML format. To get access to submitted form data you will need the unique ID of each of the form elements that you want to use, see Finding the unique element ID. To find out what the return values are for different element types, see Getting form values page. You can then display the value using the code below. Replace iphorm_X_X with your form element unique ID.

1
<?php echo $form->getValueHtml('iphorm_X_X'); ?>
<?php echo $form->getValueHtml('iphorm_X_X'); ?>

An example of autoreply-content.php is shown below.

1
2
3
Thanks for your message, <?php echo $form->getValueHtml('iphorm_1_1'); ?>!<br />
<br />
We will respond to you within 24 hours to your submitted email address: <?php echo $form->getValueHtml('iphorm_1_2'); ?><br />
Thanks for your message, <?php echo $form->getValueHtml('iphorm_1_1'); ?>!<br />
<br />
We will respond to you within 24 hours to your submitted email address: <?php echo $form->getValueHtml('iphorm_1_2'); ?><br />

Step 3

Upload the file autoreply-content.php to wp-content/themes/YOUR_THEME/autoreply-content.php.

Step 4

Add the following code to the wp-content/themes/YOUR_THEME/functions.php file (or create a plugin for it).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function my_customize_autoreply($mailer, $form, $attachments)
{
    // Get the new email content from the file autoreply-content.php
    ob_start();
    include dirname(__FILE__) . '/autoreply-content.php';
    $content = ob_get_clean();
 
    // Set the email content
    $mailer->MsgHTML($content);
 
    // You must return the $mailer object
    return $mailer;
}
add_filter('iphorm_pre_send_autoreply_email_1', 'my_customize_autoreply', 10, 3);
function my_customize_autoreply($mailer, $form, $attachments)
{
    // Get the new email content from the file autoreply-content.php
    ob_start();
    include dirname(__FILE__) . '/autoreply-content.php';
    $content = ob_get_clean();

    // Set the email content
    $mailer->MsgHTML($content);

    // You must return the $mailer object
    return $mailer;
}
add_filter('iphorm_pre_send_autoreply_email_1', 'my_customize_autoreply', 10, 3);
  • On line 14, change the number 1 to the unique ID of the form, from Step 1.

See also

Getting form values

Still having trouble? Head over to the forums.

Forums