Show All Merge Tags Gravity Form

GravityWPGravityForms, Plugin0 Comments

Do you want to have a list of all the merge tags from a specific form? With our simple plugin you have a special admin page or can use a shortcode to get all the merge tags from a specific gravity form. No more clicking on a dropdown to select the merge tag you need, but just copy and paste it from the list.

How it works?

Imagine, you have a Gravity Form. And you want to have an easy way to show all the Merge Tags from that specific form, without having to click on it inside the confirmations or notifications area? Take for example this form:

Merge tags:

{You are a:5}
{First name:2}
{Last name:3}
{Title:4}

Gravity Forms admin page with merge tags

Just install the plugin ‘GravityWP – Merge Tags‘ from the WordPress repository and there will be a toolbar link en menu link available in your dashboard to get a list of all your merge tags (from a specific Gravity Form):

Shortcode to show all merge tags Gravity Forms

Just install the plugin ‘GravityWP – Merge Tags‘ from the WordPress repository and use this shortcode to get a list of all your merge tags (from a specific Form ID):


[[gravitywp_mergetags formid="1"]]

Download the plugin (WordPress)

You can also use the snippet

Instead of using the ‘GravityWP – Merge Tags‘ plugin, you can also add this snippet to your functions.php file in your theme. Alert! You won’t get any updates on the code (with the plugin you will get them automatically in WordPress). But if you don’t want to install the plugin, just add this:

function gravitywp_get_mergetags( $atts, $content = null ) {
		extract( shortcode_atts( array(
		'formid' => '0'
		), $atts ) );
		ob_start();
		$form_id = $formid;
        $form = RGFormsModel::get_form_meta($form_id);
        $fields = array();

        if(is_array($form["fields"])){
            foreach($form["fields"] as $field){
                if(isset($field["inputs"]) && is_array($field["inputs"])){

                    foreach($field["inputs"] as $input)
					    echo "&#123;" . GFCommon::get_label($field, $input["id"]) . ":" . $input["id"] . "&#125;<br>";
                }
                else if(!rgar($field, 'displayOnly')){
                    echo "&#123;" . GFCommon::get_label($field) . ":" . $field["id"] . "&#125;<br>";
                }
            }
        }
		
		$output_string = ob_get_contents();
		ob_end_clean();
		return $output_string;
    }
	
add_shortcode( 'gravitywp_mergetags', 'gravitywp_get_mergetags' );

Share this Post