When working with Gravity Forms, many times you want to show dynamic data after form submit.
Like:
- Show different content based on user answer
- Run your own PHP function
- Display custom posts or data
But problem comes when you try to mix everything.
-> What is the issue
Gravity Forms gives conditional shortcode like this:
[gravityforms action="conditional" merge_tag="{:3:value}" condition="contains" value="E"]</span>
<span> Some content here</span>
<span>[/gravityforms]Looks good, butโฆ
- You canโt add PHP code inside it
- You canโt use another shortcode inside it
- So your custom function will not run
Example that fails:
[gravityforms ...]</span>
<span> [useful-tools]</span>
<span>[/gravityforms]-> What we actually want
You already have:
PHP function:
useful_tools_list(array( 'type' => 'documents', 'desc' => 'true' ))
Shortcode:
[useful-tools type="documents" desc="true"]
Now you just want:
๐ Show this only when condition is true
-> Simple working idea
Donโt use Gravity Forms conditional shortcode.
๐ Put condition inside your shortcode.
Yes, very simple.
-> Step 1: Update shortcode usage
Add 2 extra things:
[useful-tools type="documents" desc="true" merge_tag="{:3:value}" value="B"]
-> Step 2: Add condition inside PHP
Now edit your shortcode function.
Main logic is this:
if (($atts['merge_tag']) && (!preg_match('/\b'.$atts['value'].'\b/', $atts['merge_tag']))) {
return '';
}
What this does:
- Takes value from form field
- Checks if it matches
- If not โ returns nothing
-> Full working flow
- User submits form
- Gravity Forms passes field value (
{:3:value}) - Shortcode receives it
- PHP checks condition
- If match โ show data
- If not โ nothing shows
-> Why this method is good
- No need to write full PHP confirmation
- Editor still usable for team
- Clean and simple logic
- Works with any custom function
-> Other method (not easy)
You can use:
gform_confirmation
And then run:
do_shortcode()
But problem:
- Everything goes in PHP
- Non-tech users canโt edit
So better avoid if working in team.
-> Small tip
Whenever:
- Shortcode not working inside shortcode
- PHP not allowed in editor
๐ Move logic inside your own shortcode
This trick works in many WordPress cases.
-> Final words
Gravity Forms has limits.
But with small change in shortcode, you can:
- Add condition
- Run PHP function
- Show dynamic content
Simple solution, less headache.

