☰
Documentation

Nested Modifiers

Sometimes you want to use multiple modifiers to perform actions on the value of the Merge Tag before returning it to the context you’re in. You can do that with using nested modifiers inside an Advanced Merge Tags modifier.

Example gwp_replace

For example when using gwp_replace to replace part of string with another string, you normally use it like this:

{Example:1:gwp_replace search="GravityWP" replace="GWP"}

With this modifier, we can replace ‘GravityWP’ with the abbreviation ‘GWP’. When we have for example the string ‘GravityWP is cool!’, when using the above modifier, it will return ‘GWP is cool!’.

But what if we want to replace another part of the string with something else? You can do that with adding another nested modifier like this:

{Example:1:gwp_replace search="GravityWP" replace="GWP" modifier1='gwp_replace search="cool" replace="awesome"'}

As you see, we now replace with the nested modifier all instances of ‘cool’ with ‘awesome’. Our example ‘GravityWP is cool!’ will now return ‘GWP is awesome!’. You can use multiple nested modifiers, for example by adding modifier2=, modifier3=, etc.

modifier1='' modifier2='' modifier3=''

Make sure you start the nested modifier without the colon (punctuation) : and make sure the opening and closing apostrophes ‘ ‘ are different those used inside the nested modifier, using quotation marks ” “ or the other way around.

How nested modifiers are applied

  • The first modifier must be an Advanced Merge Tags modifier (gwp_…). The nested modifiers run in order: modifier1, then modifier2, and so on. Number them without gaps: the list stops at the first missing number.
  • Each nested modifier works on the result of the previous one. For lookup modifiers like gwp_get_matched_entry_value, that result is the value to match.
  • A nested modifier can also be a custom modifier from another plugin or code snippet that uses the gform_merge_tag_filter hook. Built-in Gravity Forms modifiers like :value cannot be nested; put those directly after the first advanced modifier, see Combine regular with advanced modifiers.
  • Nested modifiers also work after gwp_entry, gwp_user and gwp_eeid: {gwp_user:display_name:gwp_remove_accents modifier1='gwp_case to=lower'}.

Example of a chained lookup: find the customer of an order in form 3, then the customer’s email address in form 4:

{Order number:1:gwp_get_matched_entry_value form_id=3 match_id=1 return_id=2 modifier1='gwp_get_matched_entry_value form_id=4 match_id=1 return_id=5'}

Frequently Asked Questions

Can I apply multiple modifiers to a single Gravity Forms field?

Yes! With the Nested Modifiers feature from GravityWP’s Advanced Merge Tags, you can chain multiple modifiers to perform complex, step-by-step transformations on field values. Each modifier processes the result of the one before it. Example: {Field:1:gwp_remove_accents modifier1='gwp_case to=lower' modifier2='gwp_sanitize type=sanitize_title_with_dashes'} This removes accents, converts to lowercase, and sanitizes into a URL-friendly slug all in one line.

What’s the correct syntax for using nested modifiers?

Each nested modifier is added using modifier1=, modifier2=, etc. The value must start with the modifier name (without the colon) followed by its parameters. Be careful to alternate quote styles (use ‘ outside and ” inside). Example: {Field:1:gwp_replace search="a" replace="b" modifier1='gwp_case to=upper'}

How many nested modifiers can I use?

You can chain as many modifiers as needed using modifier1=, modifier2=, modifier3=, and so on. GravityWP processes them sequentially from top to bottom. Example: {Field:1:gwp_replace search="test" replace="done" modifier1='gwp_case to=upper' modifier2='gwp_append after=" ✅"'} This replaces text, converts it to uppercase, and appends a checkmark.

What happens if one of the modifiers is written incorrectly?

If a modifier is misspelled or its parameters are invalid, GravityWP will skip that modifier or return an error based on plugin settings. Always double-check your modifier names and syntax. Incorrect: {Field:1:gwp_remove_accents modifier1='gwp_wrongmod to=lower'} Fix: {Field:1:gwp_remove_accents modifier1='gwp_case to=lower'}

What’s a real-world use case for nested modifiers?

Suppose you’re creating a slug from a user-submitted phrase like RÉSUMÉ FRANÇAIS. You want to: -Remove accents -Convert everything to lowercase -Format it as a clean URL slug You can do it all at once: {Field:1:gwp_remove_accents modifier1='gwp_case to=lower' modifier2='gwp_sanitize type=sanitize_title_with_dashes'} Output: resume-francais

Example gwp_replace How nested modifiers are applied Frequently Asked Questions
Proudly powered by WordPress