Advertisement
chrishajer

See https://gist.github.com/richardvav/6947682

Oct 20th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. // UPDATE: see https://gist.github.com/richardvav/6947682 up to date October 20, 2013
  3. // Go there now and ignore the rest of this code
  4. //
  5. //
  6. //
  7. //
  8. //
  9. //
  10. //
  11. //
  12. //
  13. //
  14. //
  15. //
  16. //
  17. //
  18. // Help Scout 30310 Richard Vav
  19. // improved September 19 2013
  20. // to exclude a field from notifications assign the field the CSS Class Name gf_exclude and then use the {all_fields:exclude} merge tag
  21. add_filter( 'gform_merge_tag_filter', 'exclude_from_all_fields', 10, 4 );
  22. function exclude_from_all_fields( $value, $merge_tag, $options, $field ) {
  23.     $options_array = explode( ",", $options ); //breaks options into an array
  24.     $exclude = in_array( "exclude", $options_array ); //returns TRUE if 'exclude' is found in the array
  25.     $class_array = explode( " ", $field["cssClass"] ); //breaks the fields CSS classes into an array
  26.     $exclude_class = in_array( "gf_exclude", $class_array ); //returns TRUE if 'gf_exclude' is found in the array
  27.  
  28.     if ( $merge_tag == "all_fields" && $exclude == true && $exclude_class == true )
  29.         return false;
  30.     else
  31.         return $value;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement