The {get} Merge Tag

The {get} Merge Tag

Introduced in Version 1.15

The {get} Merge Tag allows you to display information passed in the URL. The {get} Merge Tag can be used inside Custom Content fields and wherever other Merge Tags are used in GravityView.

Basic use: {get:url-parameter}

Read a tutorial on using the {get} Merge Tag

The {get} Merge Tag format is {get:param}, where param is the name of the URL parameter value you want to display. For this Merge Tag: {get:first-name}, the URL parameter is first-name.

To display a person's first name in a Custom Content field using {get:first-name}, you could use the following URL:

example.com/view/my-view/?first-name=Floaty

For that URL, this sample content: My name is {get:first-name} the {get:first-name} Merge Tag is replaced with Floaty, resulting in the following text: "My name is Floaty".


Using {get} with the [gvlogic] shortcode

You can use the {get} Merge Tags to display content that is based on a value contained in an URL.

[gvlogic if="{get:aliens}" is="Definitely are green"]
    This would match: http://www.example.com/?aliens=Definitely%20are%20green
[else]
    This would NOT match: http://www.example.com/?aliens=Come%20in%20all%20colors
    This would NOT match: http://www.example.com/?aliens-do-not-exist
[/gvlogic]

How {get} displays values

There are security issues displaying data passed via URL. Because of this, GravityView uses the esc_html() function to make sure the information is safe to display.

This prevents malicious code from being added to your website by hackers.

  • URL data: ?lets-get-dangerous=<script>alert("better watch out")</script>
  • Merge Tag: {get:lets-get-dangerous}
  • Output: The output will look the same: <script>alert("better watch out")</script>, but the output HTML will be safely converted to using HTML entities to represent the data: <script>alert("better watch out")</script>. If you want to disable this sanitization,

Displaying array data

The {get} Merge Tag displays URL parameter arrays as a comma-separated value:

  • URL data: ?example[]=Example+One&example[]=Example+(with+comma)%2C+Two
  • Merge Tag: {get:example}
  • Output: Example One, Example (with comma), Two

If you want to modify the "glue" used to connect the array values, use can use the filter.

Available filters

Developers can modify the output from the {get} Merge Tag.

  • gravityview/merge_tags/get/glue/ Modify the glue used to convert an array of {get} values from an array to string
    • string $glue String used to implode() $_GET values Default: ,
    • string $property The current name of the $_GET parameter being combined
  • gravityview/merge_tags/get/esc_html/{url parameter name} Disable esc_html() from running on {get} merge tag. By default, all values passed through URLs will be escaped for security reasons. If for some reason you want to pass HTML in the URL, for example, you will need to return false on this filter. It is strongly recommended that you do not disable this filter.
    • boolean $esc_html Whether to esc_html() the value. Default: true
  • gravityview/merge_tags/get/value/{url parameter name} Modify the value of the {get} replacement before being used
    • string $value Value that will replace {get}
    • string $text Text that contains {get} (before replacement)
    • array $form Gravity Forms form array
    • array $entry Gravity Forms entry array