Creating a Variable #
- In your WordPress dashboard, go to either:
- GravityOps → Global Variables → Settings, or
- Forms → Settings → Global Variables
- Click Create New Variable.
- Give your variable a clear, descriptive slug. This slug becomes the reference you will reuse in merge tags and shortcodes.
- In the shortcode formula field, paste your shortcode (or any other shortcode-based logic) you want this variable to represent. Make sure the formula is a valid shortcode with the opening and closing shortcode tags, for example:
[gravitymath]2+4[/gravitymath]
- (Optional) Reference other variables inside this formula if you want to nest logic. Just make sure you avoid circular references.
- Click Save to create the variable.
Once saved, the variable is ready to be reused anywhere you would normally paste the underlying shortcode.
Using Variables #
Global Variables is designed to let you reuse your logic anywhere you already use merge tags and shortcodes.
Using Variables Where Merge Tags Are Supported #
Anywhere Gravity Forms supports merge tags (for example: field values, confirmations, notifications, and some HTML content areas), you can insert your variable’s merge tag instead of pasting the full shortcode.
- Open the form, notification, or setting where you want to use the variable.
- Insert the variable’s merge tag in place of the raw shortcode.
- Save your changes.
When the form runs, the plugin expands the variable into its stored shortcode and passes it to GravityMath (or the original shortcode provider) for processing.
Using Variables Where Merge Tags Are Not Supported #
In places where merge tags are not available, you can still use your variables by wrapping them with the helper shortcode:
[gvfgm_var]{your-variable-slug}[/gvfgm_var]
This tells the plugin to expand the variable into its underlying shortcode and process it as if you had pasted the shortcode directly.
Please note this is only available with the Premium or Agency plans.
Whether you use merge tags or the helper shortcode, you only maintain the logic in one place: the Global Variables screen.