### [How to Include Field Descriptions Inside Email Notifications](https://wpforms.com/developers/how-to-include-field-descriptions-inside-email-notifications/)

**Published:** April 10, 2020
**Author:** Editorial Team

**Excerpt:** This tutorial will show you how to use PHP to make sure your field descriptions are included in your email notifications. 

**Content:**

Would you like to include field descriptions inside email notifications? By default, the **{all\_fields}** includes all form fields and labels that are filled in from the form with the exception of descriptions. However, you can easily include descriptions inside email notifications using a small PHP snippet. In this tutorial, we’ll walk you through each step on how to achieve this!

Please know that these snippets will not work if you’ve selected the **Plain Text** email template.

## Creating your form

First, you’ll need to create your form. Our form will have just a few fields included and only one field will have the **Field Description** entered.

Once you’ve created your form, just complete the field descriptions you want to include in your email notification.

![Add your field descriptions to be included inside your email notifications](https://wpforms.com/wp-content/uploads/2022/05/wpforms-create-form-descriptions-in-email-notifications.jpg)

If you need any assistance in creating your form, [please visit this documentation](https://wpforms.com/docs/creating-first-form/ "Creating Your First Form").

## Selecting the Email Template

In this tutorial, you’ll need to make sure you do not have the **Plain Text** email template selected. If you’re not sure which setting you have or what this setting is, [you can always review this documentation to see where to change this option](https://wpforms.com/docs/a-complete-guide-to-wpforms-settings/#email "A Complete Guide to WPForms Settings").

![In your WPForms Settings on the Email tab, this tutorial is using the HTML Email Template setting](https://wpforms.com/wp-content/uploads/2020/04/wpforms-select-email-template.jpg)

## Including the field descriptions in the notification

Now it’s time to add the snippet to your site. If you need any help in adding snippets to your site, [please see this tutorial](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/ "How to Add Custom PHP or JavaScript for WPForms").

```

/*
 * Include field descriptions inside email notifications.
 *
 * @link https://wpforms.com/developers/how-to-include-field-descriptions-inside-email-notifications/
 */

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 . '' . $field_data[ 'description' ] . '';
 
}
add_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 20, 4 );
```

By adding this snippet, your field descriptions will be included in all of your email notifications.

![now the field descriptions will be included in each notification](https://wpforms.com/wp-content/uploads/2022/05/wpforms-descriptions-in-notifications.jpg)

And that’s it! You’ve now included the field descriptions inside your email notifications! Would you like to also hide image choices from email notifications? Take a look at the article on [How to Hide Image Choices in Notification Emails](https://wpforms.com/developers/how-to-hide-image-choices-in-notification-emails/ "How to Hide Image Choices in Notification Emails").

## Reference Filter

[wpforms\_html\_field\_value](https://wpforms.com/developers/wpforms_html_field_value/ "Using the wpforms_html_field_value filter")

## FAQ

#### Q: Can I style the field descriptions in the notification?

**A:**You can add some CSS styling to the field descriptions by using this snippet.

```

/*
 * Include field descriptions inside email notifications.
 *
 * @link https://wpforms.com/developers/how-to-include-field-descriptions-inside-email-notifications/
 */

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 . '' . $field_data[ 'description' ] . '';

}
add_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 20, 4 );
```

![Now you can add styling to the Field Descriptions with this filter](https://wpforms.com/wp-content/uploads/2020/04/wpforms-styling-field-descriptions.jpg)

#### Q: Can I target just 1 form by the form ID?

**A:** Absolutely! If you’d only like to do this for one form, use this snippet.

```

/*
 * Include field descriptions inside email notifications.
 *
 * @link https://wpforms.com/developers/how-to-include-field-descriptions-inside-email-notifications/
 */

function wpf_dev_html_field_value( $field_val, $field, $form_data, $context ) {
	
	// Only process this on form ID 780
	if ( $form_data[ 'id' ] !== '780' ) {
		return $field_val;
    }
   
    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 . '' . $field_data[ 'description' ] . '';
 
}
add_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 20, 4 );
```

You’ll need to replace the **780** in the snippet to match your own form ID. If you need help in finding your form ID, [please review this tutorial](https://wpforms.com/developers/how-to-locate-form-id-and-field-id/ "How to Locate Form ID and Field ID").

#### Q: How can I add the field descriptions to the entries?

**A:** You can include field descriptions when viewing your form entries by adding this snippet to your site.

```

/*
 * Include field descriptions inside form entries.
 *
 * @link https://wpforms.com/developers/how-to-include-field-descriptions-inside-email-notifications/
 */

function wpf_dev_html_field_value( $field_val, $field, $form_data, $context ) {
   
    if ( $context !== 'entry-single' ) {
        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 . '' . $field_data[ 'description' ];
 
}
add_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 20, 4 );

```

By using the `entry-single` we’re allowing the field descriptions to be viewed when viewing a single entry. Field descriptions will not be permanently saved on all entries using this snippet on the current entry being viewed will have the field descriptions displaying on screen.

#### Q: Can I only add certain field descriptions instead of all?

**A:**Absolutely! For this example, we’re only going to include the field descriptions for the **Name** field.

```

/*
 * Include field descriptions inside form entries.
 *
 * @link https://wpforms.com/developers/how-to-include-field-descriptions-inside-email-notifications/
 */

function wpf_dev_html_field_value( $field_val, $field, $form_data, $context ) {
	
    if ( $context !== 'email-html' ) {
        return $field_val;
    }

    if ( $field['type'] !== 'name' ) {
        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 . '' . $field_data[ 'description' ];
}
add_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 20, 4 );
```

**Categories:** Notifications

**Tags:** PHP

---

