Documentation

gwp_replace

With the gwp_replace Merge Tag Modifier for Gravity Forms you can search and replace parts of the field value before outputting it to the screen.

:gwp_replace search= replace=

If you want to change the output of a Merge Tag text, use the Modifier like this:

ExampleModifierOutput
{Example:1} GravityWP
{Example:1:gwp_replace search="ravity" replace="RAVITY"} :gwp_replace search=”ravity” replace=”RAVITYGRAVITYWP
{Example:1:gwp_replace search="WP" replace=" Forms"}:gwp_replace search=”WP” replace=” Forms”Gravity Forms

Try it

Support for Nested Mergetags

Read more about Nested Mergetags here. Example of gwp_replace to search and replace with values from other fields in your Gravity Form:

{String:1:gwp_replace search='*|Which part to replace:2|*' replace='*|Replace with:3|*'}

Support for Nested Modifiers

Read more about Nested Modifiers here. Example of gwp_replace with one nested (extra) modifier, wehere ‘GravityWP’ is replaced by ‘WP’ with the original modifier and ‘cool’ by ‘awesome’ by the nested modifier.

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

Replace multiple values

To search and replace multiple values you can use this generator, it will create up to 8 Nested Modifiers for you. Just remove the ones you don’t need.

Frequently Asked Questions

How do I replace a specific word in a Gravity Forms field using gwp_replace?

The gwp_replace merge tag modifier lets you search for a word or phrase and replace it with something else. It’s great for cleaning up text, formatting dynamic values, or customizing output in confirmations and HTML fields.

Code Example:
{My Field:1:gwp_replace search="old" replace="new"}

Can I replace text dynamically using other field values?

Yes! gwp_replace supports nested merge tags in both the search and replace parameters. This means you can use the value from one field to search, and another field to replace it dynamically.

Code Example:
{Original Text:1:gwp_replace search="*|Find This Text:3|*" replace="*|Replace with this:4|*"}

Is gwp_replace case-sensitive by default?

Yes, the search is case-sensitive unless you manually add the case_sensitive=”false” parameter. This is helpful when you want to match text regardless of capitalization.

Code Example:
{My Field:1:gwp_replace search="HELLO" replace="Hi" case_sensitive="false"}

Can I chain multiple gwp_replace modifiers together?

Absolutely! You can nest multiple replacements using modifier1, modifier2, and so on. This is handy if you want to make several replacements in one go.

Code Example:
{My Field:1:gwp_replace search="one" replace="1" modifier1='gwp_replace search="two" replace="2"'}

What if the text I’m trying to replace doesn’t exist?

f the search string isn’t found in the field’s value, the gwp_replace modifier will simply output the original value unchanged. It won’t cause errors or break your form output.

Code Example:
{My Field:1:gwp_replace search="nonexistent" replace="nothing changes"}

Last updated: 21-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