Gform merge tag filter

Description

Use this filter to dynamically change the merge tag output. Useful when filtering field types from being displayed in the {all_fields} merge tag, or implementing custom field types that require the merge tag output to be different from the value stored with the entry.

Usage

<?php
add_filter("gform_merge_tag_filter", "filter_merge_tag", 10, 4);
?>

Parameters

$value
(string) The current merge tag value to be filtered. Replace it with any other text to replace the merge tag output, or return "false" to disable this field's merge tag output.
$merge_tag
(string/int) If the merge tag being executed is an individual field merge tag (i.e. {Name:3}), this variable will contain the field's ID. If not, this variable will contain the name of the merge tag (i.e. all_fields).
$options
(string) The string containing any options for this merge tag. For example, "value,nohidden" would be the options for the following merge tag: {all_fields:value,nohidden}.
$field
(Field Object) The current Field Object

Examples

This example excludes any hidden fields from the {all_fields} merge tag as well as adds a placeholder text for the field whose ID is 2.


<?php
add_filter("gform_merge_tag_filter", "filter_all_fields", 10, 4);
function filter_all_fields($value, $merge_tag, $options, $field){

    if($merge_tag == "all_fields" && $field["type"] == "hidden")
        return false;
    else if($merge_tag == "all_fields" && $field["id"] == "2")
        return "Call us for detail";
   else 
        return $value;
}
?>

Source Code

This filter is located in common.php

Search the Documentation