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 Break field descriptions of your choice in the notifications and exclude fields of your choice from appearing in the notifications. HTML fields will be treated just like any other field so you may want to give them more meaningful labels otherwise the notification will just include the default "HTML Block" label. Also if your form uses conditional logic and your HTML field is hidden at the time the form is submitted the HTML field will not be included in the notification. Note: does not work with the product summary table.
/**
* to exclude field from notification add 'exclude[ID]' option to {all_fields} tag
* 'include[ID]' option includes HTML field / Section Break field description / Signature image in notification
* see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
* example: {all_fields:exclude[2,3]}
* example: {all_fields:include[6]}
* example: {all_fields:include[6],exclude[2,3]}
*/
add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 11, 5 );
function all_fields_extra_options( $value, $merge_tag, $options, $field, $raw_value ) {
if ( $merge_tag != 'all_fields' ) {
return $value;
}
// usage: {all_fields:include[ID],exclude[ID,ID]}
$include = preg_match( "/include\[(.*?)\]/", $options , $include_match );
$include_array = explode( ',', rgar( $include_match, 1 ) );
$exclude = preg_match( "/exclude\[(.*?)\]/", $options , $exclude_match );
$exclude_array = explode( ',', rgar( $exclude_match, 1 ) );
$log = "all_fields_extra_options(): {$field->label}({$field->id} - {$field->type}) - ";
if ( $include && in_array( $field->id, $include_array ) ) {
switch ( $field->type ) {
case 'html' :
$value = $field->content;
break;
case 'section' :
$value .= sprintf( '<tr bgcolor="#FFFFFF">
<td width="20"> </td>
<td>
<font style="font-family: sans-serif; font-size:12px;">%s</font>
</td>
</tr>
', $field->description );
break;
case 'signature' :
$url = GFSignature::get_signature_url( $raw_value );
$value = "<img alt='signature' src='{$url}'/>";
break;
}
GFCommon::log_debug( $log . 'included.' );
}
if ( $exclude && in_array( $field->id, $exclude_array ) ) {
GFCommon::log_debug( $log . 'excluded.' );
return false;
}
return $value;
}