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 exclude field from notifications give field the CSS Class Name 'gf_exclude' | |
| * to include HTML field in notifications give field the CSS Class Name 'gf_include' | |
| * add 'extra_options' option to {all_fields} tag. Example: {all_fields:extra_options} | |
| * 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 ) { | |
| $options_array = explode( ",", $options ); | |
| $extra_options = in_array( "extra_options", $options_array ); | |
| if ( $merge_tag == "all_fields" && $extra_options == true ) { | |
| $class_array = explode( " ", $field["cssClass"] ); | |
| $include_class = in_array( "gf_include", $class_array ); | |
| $exclude_class = in_array( "gf_exclude", $class_array ); | |
| if ( $exclude_class == true ) | |
| return false; | |
| elseif ( $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