Developers
Introduction
Gravity Forms has an extensive developer API that can be used to access and extend default functionality. Following is a brief description of the different areas of Gravity Forms' API. Understanding the purpose of these different areas is important to make sure the right API is used.
Data Objects
Data Objects are objects/arrays that are used across all Gravity Forms APIs. They contain core Gravity Forms information such as form configuration and form submission data (a.k.a entry data).
- Entry Object The Entry object contains all properties of a particular entry such as date created, client IP, and submitted field values.
- Form Object The Form object contains all properties of a particular form such as form title, fields, notification, and confirmation. This object is available to most of the Gravity Forms hooks and contains the following sub-objects that control different aspects of the form confiration
- Field Object The Field object contains all settings for a particular field. It is part of the Form object and can be manipulated to dynamically change the way the field is displayed.
- Notifications Object The Notifications object is an associative array containing all configured notifications for a form.
- Confirmations Object The Confirmations object is an associative array containing all configured confirmations for a form.
- Conditional Logic Object Conditional Logic, when applied to the form or page button or to any field, controls the visibility of that element based on a choice selected or a value entered by the user in other fields on the form. It can also be used to determine if a notification, confirmation or add-on feed should be used.
- Button Object The Button Object contains the settings configured for the form button, such as the button text.
PHP API
The PHP API provides tools for developers to access Gravity Forms when developing in the same server/site as Gravity Forms. Tasks such as developing a new Gravity Forms Add-On, creating a new field type or using a hook or filter to change default Gravity Forms behavior will all be covered here.
- API Functions Consisting of the GFAPI Class and Helper Functions, Gravity Forms' API functions allows developers to manipulate core Gravity Forms data such as entries, forms, notification and confirmation.
- Add-On Framework The Add-On Framework provides basic functionality for developers when creating new add-ons for Gravity Forms. It provides a set of classes that can be extended to facilitate many aspects of developing add-ons such as initialization, settings pages, permissions, feed condition and script enqueuing.
- Field Framework The Field Framework provides classes and methods that can be used to create Gravity Forms field types (i.e. Text, Name and Address fields). All Gravity Forms built-in field types use the Field Framework and custom field types can be created as well.
- Constants Gravity Forms supports a few constants for customization and initialization of data.
REST API
The REST API provides endpoints that allow interaction with Gravity Forms from an external client such as desktop, mobile app or javascript.
- v2 Gravity Forms latest REST API is an extension of WordPress' REST API and allows developers to create, read, update and delete forms, entries, and results over HTTP.
- v1 Formerly called the Web API, v1 loosely follows REST-style principles and allows developers to create, read, update and delete forms, entries, and results. Here are some examples of its use. Although still supported, we highly recommend developers to use v2 instead.
Hooks
Gravity Forms provide an extensive list of actions and filters that can be used to modify almost any aspect of Gravity Forms default functionality.
- Action Hooks Discover the different action hooks available within Gravity Forms. Action hooks allow you to perform additional actions when an event takes place.
- Filters Discover the different filter hooks available within Gravity Forms. You can use filters to modify data to better match your particular needs.
- JavaScript Discover the different JavaScript hooks available within Gravity Forms. You can use JavaScript hooks to perform actions or modify data as the user interacts with the form.