This filter is applied to entry field values in various places. It’s used to make the field value more visual when viewing the entry value.


(string) The value.
(array) The field.
(array) Processed form settings/data, prepared to be used later.
(string) Context usage.



More Information

The filter is used to display a more visual graphic in the Entries list rather than just the pure HTML value that is stored in the database.


The Rating field value is stored as an integer. If a reader provides a 4 out of 5-star rating, the value saved is in the entry is 4.

When viewing the entry information (entries table, single entry details) and when notification emails are generated, this filter converts the value and returns a visual representation,

 * Filter used to convert a given entry value to a more robust visual format.
 * In this example, if a hex color code is given in a text value, it's converted
 * to a link to view more details about the color.
 * @link
 * @param  string  $value      The value.
 * @param  array   $field      The field.
 * @param  array   $form_data  Processed form settings/data, prepared to be used later.
 * @param  string  $context    Context usage.
 * @return string 

function wpf_dev_html_field_value( $value, $field, $form_data, $context = '' ) {
	// Limit this customization the text field values.
	if ( ! empty( $field[ 'value' ] ) && 'text' === $field[ 'type' ] ) {

		// Check if field value appears to be hex color format, eg #FFFFFF.
		$hex_code = sanitize_hex_color( $field[ 'value' ] );
		if ( ! empty( $hex_code ) ) {

			// Remove pound sign.
			$hex_code = str_replace( '#', '', $field[ 'value' ] );

			return '<a href="' . $hex_code . '" target="_blank">#' . $hex_code . '</a>';

	return $value;
add_filter( 'wpforms_html_field_value', 'wpf_dev_html_field_value', 10, 4 );

Using the wpforms_html_field_value filter

Snippet References: