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 Datepicker
Add a Datepicker with calendar select to a column or multiple columns in a Gravity Forms List Field.
Advanced Number Field
Functionality for Number Fields, like rounding or only absolute numbers, fixed point notation, range calculation, custom units like % or m2 & show as slider.
List Text
Add features like textarea, placeholder and custom validation to a column or multiple columns in a Gravity Forms List Field.
JWT Prefill
Fill forms with data you can trust. Prefill Gravity Forms fields with a secure token instead of links with editable url parameters, so your data is accurate, tamper-proof, and ready to use.
Read tutorials about
Gravity Forms Discount Code Field: Apply Fixed or Percentage Discounts in a Form
Learn how to create a Gravity Forms discount code field that applies fixed or percentage discounts. This tutorial shows how to calculate subtotals, discount amounts, and final totals using tested form logic.
Gravity Forms Zoom Integration: Create Zoom Meetings From Booking Forms
Learn how to connect Gravity Forms to Zoom without Zapier using GravityWP API Connector. This step-by-step tutorial shows how to create Zoom meetings from booking form submissions and save the returned meeting details back to Gravity Forms.
Gravity Forms monday.com Integration: Create New Items From Form Submissions
Learn how to connect Gravity Forms to monday.com without Zapier using GravityWP API Connector. This step-by-step tutorial shows how to create new monday.com items from form submissions and save the returned monday.com item ID back to Gravity Forms.
Gravity Forms Pipedrive Integration: Send Form Contacts to Pipedrive Without Zapier
Learn how to connect Gravity Forms to Pipedrive without Zapier using GravityWP API Connector. This step-by-step tutorial shows how to send form contacts, custom fields, and the returned Pipedrive Person ID directly from WordPress to Pipedrive CRM.