Adding extra data to the default notification email

This guide will show you how to add the form URL and user IP address to the bottom of the default notification email. 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
15
16
17
function my_custom_email_data($mailer, $form, $attachments)
{
    $formUrl = isset($_POST['form_url']) ? $_POST['form_url'] : '';
    $userIP = iphorm_get_user_ip();
 
    if ($formUrl) {
        $mailer->Body .= '<p>Form URL: <a href="' . esc_url($formUrl) . '">' . $formUrl . '</a></p>';
    }
 
    if ($userIP) {
        $mailer->Body .= '<p>User IP: ' . $userIP . '</p>';
    }
 
    // You must return the $mailer object
    return $mailer;
}
add_filter('iphorm_pre_send_notification_email_1', 'my_custom_email_data', 10, 3);
function my_custom_email_data($mailer, $form, $attachments)
{
	$formUrl = isset($_POST['form_url']) ? $_POST['form_url'] : '';
	$userIP = iphorm_get_user_ip();

	if ($formUrl) {
		$mailer->Body .= '<p>Form URL: <a href="' . esc_url($formUrl) . '">' . $formUrl . '</a></p>';
	}

	if ($userIP) {
		$mailer->Body .= '<p>User IP: ' . $userIP . '</p>';
	}

    // You must return the $mailer object
    return $mailer;
}
add_filter('iphorm_pre_send_notification_email_1', 'my_custom_email_data', 10, 3);
  • On line 17 change the number 1 to the form ID you want this to apply to. To apply this to all forms, remove the _1 from this line.

Still having trouble? Head over to the forums.

Forums