Skip to content

Instantly share code, notes, and snippets.

@bhwebworks
Created December 1, 2016 02:59
Show Gist options
  • Select an option

  • Save bhwebworks/b64bec11a0b451865edfb6d1953e8a53 to your computer and use it in GitHub Desktop.

Select an option

Save bhwebworks/b64bec11a0b451865edfb6d1953e8a53 to your computer and use it in GitHub Desktop.
The Gravity Forms {all_fields} merge tag in notifications includes all fields which had data entered, it doesn't include HTML fields, Section Break descriptions, nor does it allow you to omit fields from the notification. By adding the following code to your themes functions.php file you will gain the ability to include HTML fields, and Section …
//to include a HTML field in notifications assign the field the CSS Class Name 'gf_include' and then use the {all_fields:html} merge tag
add_filter( 'gform_merge_tag_filter', 'include_html_all_fields', 10, 4 );
function include_html_all_fields( $value, $merge_tag, $options, $field ) {
$options_array = explode( ",", $options ); //breaks options into an array
$include = in_array( "html", $options_array ); //returns TRUE if 'html' is found in the array
$class_array = explode( " ", $field["cssClass"] ); //breaks the fields CSS classes into an array
$include_class = in_array( "gf_include", $class_array ); //returns TRUE if 'gf_include' is found in the array
if ( $merge_tag == "all_fields" && $include == true && $include_class == true && $field["type"] == "html" )
return $field["content"];
else
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment