Introduction
The following GFAPI methods are used to manage form Feeds. Each Feed contains the properties which determine if and how the form submission is processed by an add-on.
See the GFAPI article for other available methods.
get_feeds
GFAPI::get_feeds()
was added in Gravity Forms version 1.8, it is used to get all feeds which match the given search criteria.
public static function get_feeds( $feed_ids = null, $form_id = null, $addon_slug = null, $is_active = true ) {}
Parameters
- $feed_ids null|integer|array
Optional. The ID of the Feed or an array of Feed IDs.
- $form_ids null|string|array
Optional. The ID of the Form to which the Feeds belong. Since 2.6.1 an array of IDs can be used to return feeds for multiple forms.
- $addon_slug null|string
Optional. The slug of the add-on to which the Feeds belong, including the gravityforms prefix. See the Gravity Forms Add-On Slugs article for a list of possible slugs.
- $is_active boolean
Optional. Default true. Indicates if only active or inactive feeds should be returned. Since 2.4.23.4 null can be used to return both.
Returns
- $result array|WP_Error
An array of Feed Objects or a WP_Error instance.
Usage Examples
Getting all active feeds.
$result = GFAPI::get_feeds();
Getting a specific feed.
$result = GFAPI::get_feeds( 1 );
Getting multiple specific feeds.
$result = GFAPI::get_feeds( array( 1, 5 ) );
Getting all active feeds for a specific form.
$result = GFAPI::get_feeds( null, 2 );
Getting all active feeds for a specific add-on.
$result = GFAPI::get_feeds( null, null, 'gravityformszapier' );
get_feed
GFAPI::get_feed()
was added in Gravity Forms version 2.4.23.4, it is used to get a specific feed.
public static function get_feed( $feed_id ) {}
Parameters
- $feed_id integer
The ID of the feed to retrieve.
Returns
- $result array|WP_Error
The Feed Object or a WP_Error instance.
Usage Examples
$result = GFAPI::get_feed( 1 );
add_feed
GFAPI::add_feed()
was added in Gravity Forms version 1.8, it is used to add a new feed to the specified form with the given configuration.
public static function add_feed( $form_id, $feed_meta, $addon_slug ) {}
Parameters
- $form_id integer
The ID of the form to which the feed belongs.
- $feed_meta array
The feed properties, see the meta property of the Feed Object.
- $addon_slug string
The slug of the add-on to which the Feed belongs, including the gravityforms prefix. See the Gravity Forms Add-On Slugs article for a list of possible slugs.
Returns
- $result WP_Error|integer
A WP_Error if an error occurs or the ID of the Feed returned by the database.
Usage Examples
$result = GFAPI::add_feed( $form_id, $feed_meta, $addon_slug );
delete_feed
GFAPI::delete_feed()
was added in Gravity Forms version 1.8, it is used to delete a specific Feed.
public static function delete_feed( $feed_id ) {}
Parameters
- $feed_id integer
The ID of the Feed Object to be deleted.
Returns
Usage Examples
$result = GFAPI::delete_feed( $feed_id );
update_feed
GFAPI::update_feed()
was added in Gravity Forms version 1.8, it is used to update the meta for a specific Feed.
public static function update_feed( $feed_id, $feed_meta, $form_id = null ) {}
Parameters
- $feed_id integer
The ID of the Feed Object to be updated.
- $feed_meta array
The feed properties, see the meta property of the Feed Object.
- $form_id integer
The ID of the form to which the feed belongs.
Returns
Usage Examples
$result = GFAPI::update_feed( $feed_id, $feed_meta, $form_id );
feed_exists
GFAPI::feed_exists()
was added in Gravity Forms version 2.4.24, it is used to check if a Feed exists for the given ID.
public static function feed_exists( $feed_id ) {}
Parameters
- $feed_id integer
The ID to be checked.
Returns
- $result boolean
Whether or not a Feed Object exists for the supplied ID.
Usage Examples
$result = GFAPI::feed_exists( $feed_id );
update_feed_property
GFAPI::update_feed_property()
was added in Gravity Forms version 2.4.24, it is used to update the properties of a specific Feed.
public static function update_feed_property( $feed_id, $property_name, $property_value ) {}
Parameters
- $feed_id integer
The ID of the Feed Object to be updated.
- $property_name string
The name of the property (column) being updated. Supported: form_id, is_active, feed_order, meta, and addon_slug
- $property_value string|integer|array
The new value of the specified property. The meta property can be passed as an associative array or JSON.
Returns
Usage Examples
$result = GFAPI::update_feed_property( $feed_id, $property_name, $property_value );
$result = GFAPI::update_feed_property( 1, 'is_active', 0 );
maybe_process_feeds
GFAPI::maybe_process_feeds()
was added in Gravity Forms 2.9.2, it can be used to trigger processing of non-payment add-on feeds for the given entry by all or a specific feed add-on.
public static function maybe_process_feeds( $entry, $form, $addon_slug = '', $reset_meta = false ) {}
Parameters
- $entry Entry Object
The entry to be processed.
- $form Form Object
The form the entry belongs to.
- $addon_slug string
A specific add-on slug, or an empty string for all non-payment add-on feeds to be processed.
- $reset_meta boolean
Indicates if the processed feeds meta for the entry should be reset.
Returns
- $result boolean|Entry Object
The entry returned by the add-ons that processed the feed, or false when there isn’t an active feed add-on, or if an instance of the specified add-on does not exist.
Usage Examples
This example would trigger processing of all non-payment add-on feeds for the given entry and form.
$result = GFAPI::maybe_process_feeds( $entry, $form );
This example would trigger processing of feeds for a specific add-on.
$result = GFAPI::maybe_process_feeds( $entry, $form, 'gravityformswebhooks' );
This example would delete the processed feeds meta before triggering processing of feeds for all non-payment add-ons.
$result = GFAPI::maybe_process_feeds( $entry, $form, '', true );
get_processed_feeds_meta
GFAPI::get_processed_feeds_meta()
was added in Gravity Forms 2.9.2, it can be used to retrieve the value of the processed_feeds meta for the specified entry.
public static function get_processed_feeds_meta( $entry_id, $addon_slug = '' ) {}
Parameters
- $entry_id integer
The ID of the entry the meta is to be retrieved for.
- $addon_slug string
A specific add-on slug to return the IDs for a specific add-on, or an empty string to return the meta for all add-ons.
Returns
- $meta array
An array of feed IDs for a specific add-on, or an array using the add-on slugs as the keys to the arrays of feed IDs.
Usage Examples
The following example would retrieve the meta for a specific add-on for the specified entry.
$feed_ids = GFAPI::get_processed_feeds_meta( $entry_id, 'gravityformswebhooks' );
The following example would retrieve the entire value of the processed_feeds meta for the specified entry.
$meta = GFAPI::get_processed_feeds_meta( $entry_id );
update_processed_feeds_meta
GFAPI::update_processed_feeds_meta()
was added in Gravity Forms 2.9.2, it can be used to update the value of the processed_feeds meta for the specified entry.
public static function update_processed_feeds_meta( $entry_id, $addon_slug, $value, $form_id = null ) {}
Parameters
- $entry_id integer
The ID of the entry the meta is to be updated for.
- $addon_slug string
An add-on slug when updating the meta for a specific add-on, or an empty string to update the meta for all add-ons.
- $value integer|array|null
The ID of a processed feed for a specific add-on, an array of processed feed IDs for a specific add-on, an array using add-on slugs as the keys to arrays of processed feed IDs, or null to clear the meta.
- $form_id null|integer
The form ID of the entry (optional, saves extra query if passed when creating the metadata).
Returns
GFAPI::update_processed_feeds_meta()
does not return a result.
Usage Examples
The following example would delete the feed IDs of the specified add-on from the process_feeds meta of the specified add-on.
GFAPI::update_processed_feeds_meta( $entry_id, 'gravityformswebhooks', null );