Description
The wpforms_email_message
filters the email message output that is sent.
Parameters
- $message
- (string) (Required) Email message, including processed Smart Tags.
- $emails
- (object) (Required) Instance of the
WPForms_WP_Emails
class, which handles all notification emails sent by WPForms.
Source
wpforms/includes/emails/class-emails.php
More Information
The wpforms_email_message
filter is applied to all emails that are sent from WPForms such as processed Smart Tags and includes the dashes separating the labels of each form field.
Examples
When sending plain text emails, it may be necessary to remove these dashes so that you can parse your email information into a Google spreadsheet (for example).
/** * Filters dashes from labels on plain text email. * * @link https://wpforms.com/developers/wpforms_email_message/ * * @param string $message Email message including Smart Tags. * @param object $emails Instance of the WPForms_WP_Emails class * @return string */ function wpf_dev_email_message( $message, $emails ) { // Remove dashes from labels $email = str_replace( array( '--- ', ' ---' ), '', $message ); return $email; } add_filter( 'wpforms_email_message', 'wpf_dev_email_message', 10, 2 );
Related
Tutorial Reference: How to Customize the Styles on the Email Template
FAQ
Q: Why are there 2 different directories for templates?
A: Within WPForms template directory, you’ll notice /wpforms/includes/emails/templates
and /wpforms/templates/emails
. There are differences between these 2 folders, so if you’re creating your own template, please be sure to follow the guide above for naming and storing your files. The email template found in the /wpforms/includes/
directory is only used to generate content for Notification emails related to the forms.
The /wpforms/templates/
folder contains various files, with the ones labeled with general used for system-related emails such as when a form import process is completed. The templates labeled with summary are used for the Email Summaries template.