Description
The wpforms_plaintext_field_value
filter is applied to email notifications when the Plain Text email template.
Parameters
- $field_value
- (string) The field value.
- $field
- (array) The field.
- $form_data
- (array) Processed form settings/data, prepared to be used later.
Source
wpforms/includes/emails/class-emails.php
More Information
The filter is used to display form information in plain text formats.
Examples
In this example, we’re going to use the wpforms_plaintext_field_value
filter to include the field descriptions inside the email notification.
/** * Filter used to provide field descriptions inside plain text emails. * * @link https://wpforms.com/developers/wpforms_plaintext_field_value/ * * @param string $field_value The field value. * @param array $field The field. * @param array $form_data Processed form settings/data, prepared to be used later. * * @return string */ function wpf_dev_plaintext_field_value( $field_value, $field, $form_data ) { if ( empty( $form_data[ 'fields' ][ $field[ 'id' ] ] ) ) { return $field_value; } $field_data = $form_data[ 'fields' ][ $field[ 'id' ] ]; if ( empty( $field_data[ 'description' ] ) ) { return $field_value; } $field_value = str_replace( [ "\r", "\n" ], '', $field_value ); return $field_value . "\r\n" . $field_data[ 'description' ] . "\r\n\r\n"; } add_filter( 'wpforms_plaintext_field_value', 'wpf_dev_plaintext_field_value', 10, 3 );
Related
Article Reference: How to Include Field Descriptions Inside Email Notifications