Would you like to include non-input fields in your notifications? To keep the flow of the notification email matching your form you may want to include things like the Page Break, Section Dividers, HTML, and Content fields. 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.
Please note that if you’re using the Plain Text Email Template, this snippet will not work for you. To check which Email Template you have selected, navigate to WPForms » Settings » Email.
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.
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, HTML, and Content 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', 'content' ); } add_filter( 'wpforms_email_display_other_fields', 'wpf_dev_email_display_other_fields', 10, 1 );
And that’s it! Your Page Breaks, Section Dividers, HTML, and Content 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.
Reference Filter
wpforms_email_display_other_fields
FAQ
Q: Why isn’t my HTML field showing?
A: When using this snippet, your Page Breaks, Section Dividers and HTML fields will only show if you use the {all_fields}
Smart Tag. If you try and pull in these particular fields on their own by calling the field ID inside the email notification, they will not display.
Also, make sure that you have set the Email Template option in the Settings of WPForms is not set to Plain Text as mentioned above.