How to Include Page Break, Section Divider, and HTML fields in notifications

Overview

Are there some special form fields you’d like to include in your notification emails? To keep the flow of the notification email matching your form you may want to include things like the Page Break and Section Dividers. Using PHP we’ll show you how you can include these fields in your email notifications.

Automatic notification emails for WPForms will, by default, include the {all_fields} Smart Tag. This will display all input fields (field labels and selections/input) that a user filled out within an HTML email template.

To also include non-input fields (Page Break, Section Divider, and HTML fields), you can add the code below to your site.

It’s important to note that some content will not display properly in emails (this will vary based on the specific content, as well as the email provider used to view the email). Due to the issues that can result from HTML content, we recommend only including the fields you absolutely need in notification emails.

Implmentation Options

We’ve included two examples, depending on which fields you need to include. Also, be sure to test your notification emails after adding this code.

Page Breaks and Section Dividers only

This code shown below will only include the Page Breaks and Section Dividers in your email notifications.

/**
 * Filters non-input field types to include in {all_fields} output.
 *
 * @link   https://wpforms.com/developers/include-page-break-section-divider-and-html-fields-in-notifications/
 *
 * @param  array $fields
 * @return array
 */
function wpf_dev_email_display_other_fields( $fields ) {

	return array( 'divider', 'pagebreak' );
}

add_filter( 'wpforms_email_display_other_fields', 'wpf_dev_email_display_other_fields', 10, 1 );

All non-input fields

Alternatively, you can use this code to show all non-input fields such as Page Breaks, Section Dividers and HTML fields.

/**
 * Filters non-input field types to include in {all_fields} output.
 *
 * @link   https://wpforms.com/developers/include-page-break-section-divider-and-html-fields-in-notifications/
 *
 * @param  array $fields
 * @return array
 */
function wpf_dev_email_display_other_fields( $fields ) {

	return array( 'divider', 'pagebreak', 'html' );
}

add_filter( 'wpforms_email_display_other_fields', 'wpf_dev_email_display_other_fields', 10, 1 );

And that’s it! Your Page Breaks, Section Dividers and HTML form fields will now be included in your notification emails. Would you like to hide the images from your notification emails when using Image Choices on your select fields? Please review our article on How to Hide Image Choices in Notification Emails.

Filter Reference: wpforms_email_display_other_fields