• Skip to primary navigation
  • Skip to content

GravityWP

The best information about Gravity Forms, GravityView, Gravity Flow and other addons

  • Tutorials
  • Forms
  • Views
  • Workflow
  • PDF
  • Charts
  • Perks
  • Show Search
Hide Search
Erik van Beek

Merge Tag Modifier Gravity Forms

Erik van Beek · Oct 14, 2017 ·

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.

Gravity Forms Documentation GravityView Documentation
  1. Create a Merge Tag modifier for uppercase

Create a Merge Tag modifier for uppercase

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 );
You can see we do different things in the PHP code:
  • add a filter to the gform_merge_tag_filter hook
  • check if it's not used in the all_fields Merge Tag from Gravity Forms (since this is a unique merge tag to output all the data in a table, we don't want to attach our modifier to that one)
  • check if the modifier is gwp_uppercase
  • do something with the value that is passed (this is the value that the visitor filled in in the specific field you refer to with the modifier)
  • in our case: we use the PHP standard function strtoupper to make all the letters uppercase

How to use your uppercase Merge Tag modifier?

After adding your fresh PHP code to your functions.php file in your theme or child theme, 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}

Hire the best developers for Gravity Forms

If you’re looking for good and experienced Gravity Forms developers to help you with your questions about Gravity Forms (like Merge Tag Modifier Gravity Forms) and other add-ons, we advice you to hire experts on Codeable. Codeable is by far the most professional, dedicated and fun community to find the freelancer you need to help you with your WordPress questions.

Click here to visit Codeable
Gravity Forms Documentation GravityView Documentation

Gravity Forms

© 2019 - This website is made possible by the wonderful services of
WordPress, GravityForms, GravityView, GravityWiz, Genesis Framework & WP Engine

  • About
  • Hire GF developers
  • Cheat Sheet