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
| s | u | b | s | t | r | i | n | g |
|---|---|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| Merge Tag & Modifier | Output |
|---|---|
{String:1} | substring |
{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 |
Our Premium add-ons for Gravity Forms
List Dropdown
Add a Dropdown Select with choices to a column or multiple columns in a Gravity Forms List Field.
Advanced Merge Tags
This Gravity Forms Add-On adds extra Merge Tag modifiers (and a lot of power). From the most common used functions like capitalize and length to changing date formats.
All Entries
All your new Gravity Forms entries in one central place. Stop navigating between multiple forms to find new entries. Get immediate oversight and full control with a powerful, unified dashboard.
Update Multiple Entries
Trigger the update of multiple entries in a target form by submitting an entry in a trigger form.
Read tutorials about
Show Previous Gravity Forms Submissions Using Advanced Merge Tags
This step-by-step tutorial shows how to use GravityWP Advanced Merge Tags to count previous Gravity Forms submissions and calculate total submitted value based on a matching email address.
Gravity Forms LeadConnector Integration with OAuth 2.0
This documentation-based tutorial explains how to connect Gravity Forms to LeadConnector/HighLevel with OAuth 2.0, search contacts by email, and map returned CRM values back into form fields using GravityWP API Connector.
Gravity Forms Zoho CRM Integration: How to Auto-Populate Form Fields by Email
Learn how to auto-populate Gravity Forms from Zoho CRM using GravityWP API Connector. This tutorial shows how to search Zoho Contacts by email and fill form fields with the returned data.
How to Create a Public Submission Business Directory in WordPress (Gravity Forms + GravityView)
Build a moderated business directory where users submit listings through a form, admins approve entries, and approved businesses appear in a searchable GravityView directory.