gwp_length
The gwp_length Gravity Forms Merge Tag Modifier to count the number of characters. This can be handy to check if the number of characters is in line with the publishing rules for where you want to show or use the text.
:gwp_length
Examples
{text:1:gwp_length}
Example value | Modifier result |
---|---|
GravityWP | 9 |
GravityWP Advanced Merge Tags | 29 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | 123 |
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? | 865 |
Frequently Asked Questions
The :gwp_length modifier lets you count the number of characters entered into a field. It works great for Paragraph Text or Single Line Text fields when you want to validate or display character length after form submission.
Example:{Your Message:1:gwp_length}
Yes! You can display the number of characters submitted by a user right inside the confirmation message. It’s useful for feedback forms, content submission rules, or just a friendly stat.
Example:
Thank you! You wrote {Your Message:1:gwp_length}
characters.
3. Will :gwp_length count spaces and punctuation?
Absolutely. The :gwp_length modifier uses mb_strlen() behind the scenes, which counts all characters including spaces, punctuation, and special characters accurately and UTF-8 safe.
Example:
If a user writes “Hello world!”, it will return: 12{Your Message:1:gwp_length}
You can use this modifier with Paragraph Text and Single Line Text fields. It won’t work on fields that don’t produce a standard string value (like checkboxes or lists).
Example:{Text Field:3:gwp_length}
Simply preview your form, fill in the targeted field, and submit it. The confirmation should display the correct character count. In our test, a 50-character sentence was counted perfectly with this setup.
Example output:Input: “You don't have to be beautiful to turn me on!”
Confirmation: “Thank you! You wrote 50 characters.”
Last updated: 21-07-2025