Home / Admin / Include Field Descriptions Inside Email Notifications
Duplicate Snippet

Embed Snippet on Your Site

Include Field Descriptions Inside Email Notifications

This snippet will have all field descriptions from all forms included in the email notifications.

50+
Code Preview
php
<?php
/* 
Include field descriptions inside email notifications
Original doc link: https://wpforms.com/developers/how-to-include-field-descriptions-inside-email-notifications/
For support, please visit: https://www.facebook.com/groups/wpformsvip
*/
function wpf_dev_html_field_value( $field_val, $field, $form_data, $context ) {
   
    if ( $context !== 'email-html' ) {
        return $field_val;
    }
 
    if ( empty( $form_data[ 'fields' ][ $field[ 'id' ] ] ) ) {
        return $field_val;
    }
 
    $field_data = $form_data[ 'fields' ][ $field[ 'id' ] ];
 
    if ( empty( $field_data[ 'description' ] ) ) {
        return $field_val;
    }
 
    return $field_val . '<p>' . $field_data[ 'description' ] . '</p>';
 
}
add_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 20, 4 );

Comments

Add a Comment