Created
December 1, 2016 02:59
-
-
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 …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * to include HTML fields or exclude fields from notifications | |
| * give field the CSS Class Name 'gf_exclude' and add the 'exclude' option to the {all_fields} tag | |
| * give HTML field the CSS Class Name 'gf_include' and add the 'html' option to the {all_fields} tag | |
| * merge tag options can be stacked. example: {all_fields:exclude,html} | |
| * see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options | |
| */ | |
| add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 10, 4 ); | |
| function all_fields_extra_options( $value, $merge_tag, $options, $field ) { | |
| if ( $merge_tag == "all_fields" ) { | |
| //break string into array and then return TRUE if string is found in the array | |
| $options_array = explode( ",", $options ); | |
| $include_html = in_array( "html", $options_array ); | |
| $exclude = in_array( "exclude", $options_array ); | |
| $class_array = explode( " ", $field["cssClass"] ); | |
| $include_class = in_array( "gf_include", $class_array ); | |
| $exclude_class = in_array( "gf_exclude", $class_array ); | |
| if ( $exclude == true && $exclude_class == true ) | |
| return false; | |
| elseif ( $include_html == true && $include_class == true && $field["type"] == "html" ) | |
| return $field["content"]; | |
| else | |
| return $value; | |
| } | |
| else | |
| return $value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment