1. Home
  2. Snippets
  3. Process Smart Tags in HTML fields

Process Smart Tags in HTML fields

Heads up!

This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

For extra guidance, please see WPBeginner's tutorial on adding custom code.


Smart Tags are a useful tool to dynamically pull and display specific data within your form.

By default, Smart Tags will not be processed if placed within an HTML field. However, this functionality may be useful if, for example, you’d like to pull the name of a logged-in user or to display other details using custom Smart Tags.

To process Smart Tags included within HTML fields, you can copy the code below into your site.

Note: This will not work for Smart Tags that pull user input values (for example, {field_id="3"}).

 * Run smart tags on HTML field content.
 * @param array $properties
 * @param array $field
 * @param array $form_data
 * @return array
function wpf_dev_html_process_smarttags( $properties, $field, $form_data ) {
	$properties['inputs']['primary']['code'] = apply_filters( 'wpforms_process_smart_tags', $properties['inputs']['primary']['code'], $form_data );
	return $properties;
add_filter( 'wpforms_field_properties_html', 'wpf_dev_html_process_smarttags', 10, 3 );
Updated on June 19, 2018

Was this article helpful?