Merge Tag Modifier Gravity Forms

GravityWPGravityForms, Merge Tags0 Comments

Do you know you can add functionality to your Gravity Forms Merge Tags. This can come in handy, for example when you want to show a field input capitalized or you want to replace certain values in the field.

How to use the Merge Tag modifier?

Take for example that you want to show a certain Merge Tag value in capital letters. A simple way to do that is to add a Gravity Forms Merge Tag modifier to your functions.php.

add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value ) {
if ( $merge_tag != 'all_fields' && $modifier == 'gwp_uppercase' ) {
$value = strtoupper ( $value );
}

return $value;
}, 10, 5 );

After it, you can use the gwp_uppercase modifier to output Merge Tag values in capital letters. Use it like this:

{Your first field:1:gwp_uppercase}

Simple as that.

Make automatic links

Maybe you want to make automatic links of your merge tags, especially when you know that the input is a valid link.

add_filter( 'gform_merge_tag_filter', function ( $value, $merge_tag, $modifier, $field, $raw_value ) {
if ( $merge_tag != 'all_fields' && $modifier == 'gwp_make_url' ) {
$value = "<a href='" . $value . "'>" . $value . "</a>" ;
} return $value; }, 10, 5 );

After it, you can use the gwp_make_url modifier to output a link of your url value. Use it like this:

{Your first field:1:gwp_make_url}

Simple as that.

Share this Post