Developer Docs

Contents

Introduction

We believe in keeping Gravity Forms simple and easy to use, and a lot of thought goes into adding new functionality. Still, users often find the need to add/modify functionality to meet their needs.

This section of the documentation offers guidelines and references for anyone wishing to modify or extend Gravity Forms.

Hooks and Filters

Following is a list of available hooks and filters.

Form Loading

The following filters can be used to manipulate the form data before the form gets displayed to the screen. Tasks such as adding drop down items dynamically or pre-populating field values can be accomplished using them.

  • gform_field_choices
    Use this filter to manipulate checkbox and radio items. Can be used to allow HTML content to be displayed
  • gform_tabindex
    Use this filter to specify the tab index start value or to disable the tabindex attribute

Sublabels

In cases where translating Gravity Forms is not an option, the following filters can be used to change the sublabels of multi-input fields (i.e Name and Address).

Form Submission

The following filters can be used to manipulate the entry data when the user submits the form. Tasks such as integrating with third party systems and dynamic notification routing can be accomplished using them.

  • gform_pre_submission
    Use this hook to perform actions after form validation, but before sending notifications and storing the entry data.
  • gform_pre_submission_filter
    Use this hook to manipulate the Form Object before sending notifications and storing entry data.
  • gform_upload_path
    Use this hook to change the path where files are uploaded by the File Upload field.
  • gform_post_data
    Use this filter to manipulate submitted Post field data before the Post is created.
  • gform_post_submission
    Use this hook to perform actions after the entry has been created (i.e. feed data to third party applications).
    The Entry Object is available to this hook and contains all submitted values
  • gform_is_duplicate
    Use this hook to specify a custom duplicate validation logic for fields marked with the 'No Duplicates' rule
  • gform_confirmation_anchor
    Use this filter to enable the confirmation anchor that will automatically scroll the page to the confirmation text upon submission. Useful when embedding forms in long pages.
  • gform_validation
    Use this filter to create custom validation logic.
  • gform_validation_message
    Use this filter to change the main validation message that is displayed when the form fails validation.
  • gform_autoresponder_email
    Use this filter to dynamically change the TO email for user notifications.
  • gform_notification_email
    Use this filter to dynamically change the TO email for admin notification.
  • gform_ajax_spinner_url
    Use this filter to change the spinner icon that is displayed on AJAX forms when the form is submitted

Administration

The following filters are fired within the Gravity Forms administration allowing the customization of certain elements.

  • gform_add_field_buttons
    Use this filter to add/remove field type buttons to the form editor screen
  • gform_address_types
    Use this filter to add support for a new address type (i.e. another country)
  • gform_admin_pre_render
    Use this filter to manipulate the Form Object before an entry is displayed on the entry detail page in the administration. If you have used gform_pre_render filter to dynamically add items to a drop down field, you may also want to add those items to the entry detail screen to allow administrators to properly edit the entry.
  • gform_author_dropdown_args
    Use this filter to change the author list displayed on post fields. Do that by specifying the $args parameter that will be passed to the wp_dropdown_users($args) to retrieve the author list
  • gform_editor_js
    Use this filter to manipulate and/or add new predefined choices to the selection fields (i.e. Checkbox, Drop Down, Multiple Choice)
  • gform_predefined_choices
    Use this filter to manipulate and/or add new predefined choices to the selection fields (i.e. Checkbox, Drop Down, Multiple Choice)
  • gform_tooltips
    Use this filter to manipulate the tooltips that are displayed throughout Gravity Forms administration pages

Form Object

The Form Object is the main object in Gravity Forms. It contains all properties of a particular form (i.e. form title, fields, notification, scheduling, etc...). This object is available to most of the Gravity Forms hooks above and can be manipulated to change the way the form is displayed, notifications are sent, etc...

It is formatted as an associative array (i.e. $form["title"] retrieves the form title). For details about each property, visit the Form Object page.

Entry Object

The Entry Object contains all properties of a particular entry (i.e. date created, client IP, submitted field values, etc...). It is formatted as an associative array with field ids being the key to get the field data.

$entry["date_created"]; //returns the entry date
$entry["1"];              //returns the value associated with field 1

For details about each property, visit the Entry Object page.

Role Management

Gravity Forms introduces new capabilities to the WordPress Role system. For more information, check out the Role Management page.

Samples

Following are some samples on using Gravity Forms' hooks to modify/extend Gravity Forms functionality.

Search the Documentation