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.

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 append="✅"'}

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

Last updated: 22-07-2025

Advanced Merge Tagsv1.9.3

To use the functionalities described in this documentation, you'll need to get the GravityWP - Advanced Merge Tags add-on.

Read more