bookmark_borderShortcodes

Gravity Forms makes use of WordPress shortcodes to allow users to perform certain actions as well as display forms in WordPress pages and posts.

Form Shortcode

The form shortcode is used to display a Gravity Form. It is the primary method used to display forms within your WordPress site.

The form shortcode can be used anywhere within WordPress where shortcodes are supported. For most users, this will primarily be within the content of a WordPress post or page.

Example:

[gravityform id=1 title=false description=false ajax=true tabindex=49]
  • id
    The id of the form to be embedded. (required)
  • title
    Whether or not do display the form title. Defaults to ‘true’. (optional)
  • description
    Whether or not do display the form description. Defaults to ‘true’. (optional)
  • ajax
    Specify whether or not to use AJAX to submit the form.
  • tabindex
    Specify the starting tab index for the fields of this form.
  • field_values
    Specify the default field values. Example: field_values=’check=First Choice,Second Choice’.

A shortcode is just one method used to display a Gravity Form in WordPress. Forms can also be displayed via function call or widget. See Embedding A Form to read more detailed information on these various methods.

Conditional Shortcode

The conditional shortcode allows you to perform conditional logic in the message content of your Admin and User Notification emails as well as the Confirmation Message that is displayed when a form is submitted.

The conditional shortcode consists of an opening and closing shortcode. Any text or content contained within the opening and closing conditional shortcode will be the content that is conditionally displayed.

Please note: Nested conditional shortcodes are not supported at this time.

Example:

[gravityforms action="conditional" merge_tag="{Number:1}" condition="greater_than" value="3"]
Content you would like to conditionally display.
[/gravityforms]
  • action
    The action you would like to perform. This must be set to conditional as in the example above. (required)
  • merge_tag
    The form merge tag who’s value you are executing the conditional logic for. You can get the correct merge tag for the form data you would like to use using the insert merge tag drop down. (required)
  • condition
    The type of condition used to determine success. Available conditions are: is, isnot, greater_than, less_than, contains, starts_with, ends_with. (required)
  • value
    The value that the condition must equal in order for the condition to be met and the content displayed. (required)

Additional Example 1:

[gravityforms action="conditional" merge_tag="{Number:1}" condition="greater_than" value="10"]
This content would be displayed if the value of field id 1 is greater than 10.
[/gravityforms]

Additional Example 2:

[gravityforms action="conditional" merge_tag="{Country:5}" condition="is" value="United States"]
This content would be displayed if the value of field id 5 is United States.
[/gravityforms]

Additional Example 3:

In this example, we want to enable the shortcode if the form has been submitted.

[gravityforms action="conditional" merge_tag="{Country:5}" condition="isnot" value=""]
This content would be displayed if no value exists for field id 5.
[/gravityforms]

Shortcode Actions

user

Requires: User Registration Add-On.

Displays details from user meta fields.

Example

[gravityform action="user" key="ID" output="raw" /]

Parameters

  • id
    Obtains the user meta from a specific user ID. Defaults to the current user.

  • key
    The key to obtain from the user meta. (required)

  • output
    Defines a different output type. Defaults to raw. Possible values are:

    • raw
      Outputs the raw data stored in the user meta.
    • csv
      Outputs comma-separated values.
    • list
      Outputs an HTML-formatted list.

login

Requires: User Registration Add-On.

Displays the login form.

Example

[gravityform action="login" description="false" logged_in_message="Yay! You are logged in!" registration_link_text="Register for my super awesome site" forgot_password_text="Stop forgetting your password" /]

Parameters

  • title
    If the form title should be displayed. Defaults to true.

  • description
    If the form title should be displayed. Defaults to false.

  • logged_in_avatar
    If the user avatar should display for logged in users. Defaults to true.

  • logged_in_message
    A message to display to users who are logged in.

  • login_redirect
    Defines a URL that the user should be redirected to after they have logged in.

  • logout_redirect
    Defines a URL that the user should be redirected to after they have logged out.

  • registration_link_display
    If the registration link should be displayed. Defaults to true.

  • registration_link_text
    The text to display within the registration link. Defaults to Register.

  • forgot_password_display
    If the Forgot Password link should be displayed. Defaults to true.

  • forgot_password_text
    The text to display within the Forgot Password link. Defaults to Forgot Password.

  • tabindex
    Defines a custom tabindex.