TutorialSubstring Modifier for Gravity Forms Merge Tags

Do you want to return a portion of a Merge Tag string output? And specify an offset and length of the part of the Merge Tag output? With Advanced Merge Tags it’s as easy as it gets.

Using the gwp_substring Modifier for Gravity Forms

With the gwp_substring Modifier for Gravity Forms Merge Tags it’s possible to return a part of value (a substring of the original string). You can use the modifier like this:

:gwp_substring start= length=

The modifier has two arguments:

  • start: how many characters should it skip when using a positive value / where does the substring start. When using a negative value (for example -3), the substring will start the number of characters before the end of the value.
  • length: how many characters should be in the substring / what is the length of the substring.

Try it yourself

Example gwp_substring

This example gives back a substring of the value in the Gravity Forms field ‘String’ (with Field ID 1). It skips the first two characters and gives back 3 characters:

{String:1:gwp_substring start=2 length=3}

Offset from the end of the string

When using a negative value for the start of the substring (for example start=-3), the substring will start 3 characters before the end of the value (string).

{String:1:gwp_substring start=-3 length=1}

Examples offset and length

Merge Tag & ModifierOutput
{String:1:gwp_substring length=3}sub
{String:1:gwp_substring start=3 length=3}str
{String:1:gwp_substring start=-3}ing
{String:1:gwp_substring start=-3 length=1}i

Read more tutorials about GravityWP BV

GravityWP develops add-ons to collect and manage your data better.
All tutorials GravityWP BV

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.