How to Include Page Break, Section Divider, and HTML Fields in Notifications

Introduction

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.

the all fields smart tag will automatically include all form fields except HTML, Page Breaks, Section Dividers and empty fields

Setting the HTML Email Template option

In order for these fields to be included, you must set the Email Template to HTML Template. To do this, go to WPForms » Settings » Email. Once there, select HTML Template and click Save Settings to save the changes.

include page break and other fields in your email notifications with PHP

Some content may 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.

Creating your form

First, you’ll need to create your form and add your fields to the form. If you need assistance in creating your form, please review this documentation.

create your form and add your section divider, page break and HTML form fields

Adding the snippet to your site

We’ve included two examples, depending on which fields you need to include. You’ll need to find the snippet that works best for your needs and add the snippet to your site.

If you need help in adding snippets to your site, please see this tutorial.

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/
 */
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/
 */
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 include empty fields inside your email notifications as well? Check out our guide on How to Show Empty Form Fields in Email Notifications.

Filter Reference: wpforms_email_display_other_fields