Skip to main content

GFAPI

API for standard Gravity Forms functionality.

Supports:

  • Forms
  • Entries

Since: 1.8

Source: includes/api.php:21

Details

  • Kind: class
  • Namespace: (global)

Methods

MethodDescription
get_form()Returns the form object for a given Form ID.
get_forms()Returns all the form objects.
delete_forms()Deletes the forms with the given Form IDs.
delete_form()Deletes the form with the given Form ID.
duplicate_form()Duplicates the form with the given Form ID.
update_forms()Updates the forms with an array of form objects.
update_form()Updates the form with a given form object.
update_forms_property()Updates a form property - a column in the main forms table. e.g. is_trash, is_active, title
update_form_property()Updates the property of one form - columns in the main forms table. e.g. is_trash, is_active, title.
add_forms()Adds multiple form objects.
add_form()Adds a new form using the given Form object. Warning, little checking is done to make sure it's a valid Form object.
get_entries()Returns an array of Entry objects for the given search criteria. The search criteria array is constructed as follows:
get_entry_ids()Returns an array of Entry IDs for the given search criteria.
count_entries()Returns the total number of entries for the given search criteria. See get_entries() for examples of the search criteria.
get_entry()Returns the Entry object for a given Entry ID.
add_entries()Adds multiple Entry objects.
update_entries()Updates multiple Entry objects.
update_entry()Updates an entire single Entry object.
add_entry()Adds a single Entry object.
delete_entry()Deletes a single Entry.
update_entry_property()Updates a single property of an entry.
update_entry_field()Updates a single field of an entry.
get_notes()Get notes based on search criteria.
get_note()Get note by ID.
add_note()Create one note for an entry.
delete_note()Delete one note.
update_note()Update a note.
submit_form()Submits a form. Use this function to send input values through the complete form submission process.
validate_form()Validates the field values.
validate_field()Validates the submitted value of the specified field.
submit_form_filter_gform_pre_validation()Ensure that the state field is set when the form is submitted via GFAPI::submit_form()
get_feeds()Returns all the feeds for the given criteria.
encrypt_feed_meta()Encrypts feed meta fields based on feed settings fields configuratino and returns the resulting feed meta array.
get_encryptor()Gets the encryption service object.
set_encryptor()Sets the encryption service object to be used by GFAPI
get_feed()Returns a specific feed.
delete_feed()Deletes a single Feed.
update_feed()Updates a feed.
add_feed()Adds a feed with the given Feed object.
update_feed_property()Updates the specified feed with the given property value.
maybe_process_feeds()Triggers processing of non-payment add-on feeds for the given entry.
get_processed_feeds_meta()Returns the processed feeds meta for the specified entry.
update_processed_feeds_meta()Updates or deletes the processed feeds meta for the specified entry.
get_entry_feed_status_key()Returns the key used when saving/retrieving the feed status entry meta.
get_entry_feed_status()Retrieves the feed processing status for the specified entry from the "feed_{$feed_id}_status" meta.
update_entry_feed_status()Updates or deletes the "feed_{$feed_id}_status" meta for the specified entry.
get_feed_name()Retrieves the name of the given feed.
send_notifications()Triggers sending of active notifications for the given form, entry, and event.
send_notification()Triggers sending of the given notification.
current_user_can_any()Checks the permissions for the current user. Returns true if the current user has any of the specified capabilities.
get_fields_by_type()Returns an array containing the form fields of the specified type or types.
get_field()Returns the field object for the requested field or input ID from the supplied or specified form.
form_id_exists()Checks whether a form ID exists.
entry_exists()Checks if an entry exists for the supplied ID.
feed_exists()Checks if a feed exists for the supplied ID.
log_error()Write an error message to the Gravity Forms API log.
log_debug()Write a debug message to the Gravity Forms API log.
unique_title()Make sure the form title is unique.

Method Reference

get_form()

public static function get_form( $form_id )

Returns the form object for a given Form ID.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the Form.

Returns

  • mixed — The form meta array or false.

Since: 1.8

Source: includes/api.php:38

get_forms()

public static function get_forms( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC' )

Returns all the form objects.

Parameters

NameTypeDefaultDescription
$activebooltrueTrue if active forms are returned. False to get inactive forms. Defaults to true.
$trashboolfalseTrue if trashed forms are returned. False to exclude trash. Defaults to false.
$sort_columnstring'id'The column to sort the results on.
$sort_dirstring'ASC'The sort direction, ASC or DESC.

Returns

  • array — The array of Form Objects.

Since:

  • 1.8.11.5
  • 2.5 (added $sort_column and $sort_dir parameters.)

Source: includes/api.php:79

delete_forms()

public static function delete_forms( $form_ids )

Deletes the forms with the given Form IDs.

Parameters

NameTypeDefaultDescription
$form_idsarrayAn array of form IDs to delete.

Returns

  • void

Since: 1.8

Source: includes/api.php:106

delete_form()

public static function delete_form( $form_id )

Deletes the form with the given Form ID.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the Form to delete.

Returns

  • mixed — True for success, or a WP_Error instance.

Since: 1.8

Source: includes/api.php:128

duplicate_form()

public static function duplicate_form( $form_id )

Duplicates the form with the given Form ID.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the Form to delete.

Returns

  • mixed — True for success, or a WP_Error instance

Since: 2.2

Source: includes/api.php:155

update_forms()

public static function update_forms( $forms )

Updates the forms with an array of form objects.

Parameters

NameTypeDefaultDescription
$formsarrayArray of form objects.

Returns

  • mixed — True for success, or a WP_Error instance.

Since: 1.8

Source: includes/api.php:177

update_form()

public static function update_form( $form, $form_id=null )

Updates the form with a given form object.

Parameters

NameTypeDefaultDescription
$formarrayThe Form object
$form_idintnullOptional. If specified, then the ID in the Form Object will be ignored.

Returns

  • bool | WP_Error — True for success, or a WP_Error instance.

Since: 1.8

Source: includes/api.php:208

update_forms_property()

public static function update_forms_property( $form_ids, $property_key, $value )

Updates a form property - a column in the main forms table. e.g. is_trash, is_active, title

Parameters

NameTypeDefaultDescription
$form_idsarrayThe IDs of the forms to update.
$property_keystringThe name of the column in the database e.g. is_trash, is_active, title.
$valuemixedThe new value.

Returns

  • mixed — Either a WP_Error instance or the result of the query

Since: 1.8.3.15

Source: includes/api.php:324

update_form_property()

public static function update_form_property( $form_id, $property_key, $value )

Updates the property of one form - columns in the main forms table. e.g. is_trash, is_active, title.

Parameters

NameTypeDefaultDescription
$form_idarray | intThe ID of the forms to update.
$property_keystringThe name of the column in the database e.g. is_trash, is_active, title.
$valuestringThe new value.

Returns

  • mixed — Either a WP_Error instance or the result of the query

Since: 1.8.3.15

Source: includes/api.php:389

add_forms()

public static function add_forms( $forms, $continue_on_error=false, $accessible=false )

Adds multiple form objects.

Parameters

NameTypeDefaultDescription
$formsarrayThe Form Objects.
$continue_on_errorboolfalseControls whether the function will continue adding forms even if it encounters an error with a form. If true, the function will attempt to add all forms and will return an array of successfully added form IDs and an array of failed forms with their corresponding errors. If false, the function will return a WP_Error instance as soon as it encounters an error with a form and will not attempt to add any remaining forms.
$accessibleboolfalseControls whether forms are accessible by default. If true, properties that are not set in the specified $forms parameter will be set to an accessible value (i.e. top label). If false, defaults are not guaranteed to be accessible.

Returns

  • array | WP_Error — Either an array of new form IDs or a WP_Error instance.

Since: 1.8

Source: includes/api.php:411

add_form()

public static function add_form( $form_meta, $accessible=true )

Adds a new form using the given Form object. Warning, little checking is done to make sure it's a valid Form object.

Parameters

NameTypeDefaultDescription
$form_metaarrayThe Form object.
$accessiblebooltrueControls whether forms are accessible by default. If true, properties that are not set in the specified $forms parameter will be set to an accessible value (i.e. top label). If false, defaults are not guaranteed to be accessible.

Returns

  • int | WP_Error — Either the new Form ID or a WP_Error instance.

Since: 1.8

Source: includes/api.php:464

get_entries()

public static function get_entries( $form_ids, $search_criteria=[], $sorting=null, $paging=null, &$total_count=null )

Returns an array of Entry objects for the given search criteria. The search criteria array is constructed as follows:

Filter by status $search_criteria['status'] = 'active';

Filter by date range $search_criteria['start_date'] = $start_date; // Using the time zone in the general settings. $search_criteria['end_date'] = $end_date; // Using the time zone in the general settings.

Filter by any column in the main table $search_criteria['field_filters'][] = array("key" => 'currency', value => 'USD'); $search_criteria['field_filters'][] = array("key" => 'is_read', value => true);

Filter by Field Values $search_criteria['field_filters'][] = array('key' => '1', 'value' => 'gquiz159982170');

Filter Operators Supported operators for scalar values: is/=, isnot/<>, contains $search_criteria['field_filters'][] = array('key' => '1', 'operator' => 'contains', value' => 'Steve'); Supported operators for array values: in/=, not in/<>/!= $search_criteria['field_filters'][] = array('key' => '1', 'operator' => 'not in', value' => array( 'Alex', 'David', 'Dana' );

Filter by a checkbox value - input ID search keys $search_criteria['field_filters'][] = array('key' => '2.2', 'value' => 'gquiz246fec995'); NOTES: - Using input IDs as search keys will work for checkboxes but it won't work if the checkboxes have been re-ordered since the first submission. - the 'not in' operator is not currently supported for checkbox values.

Filter by a checkbox value - field ID keys Using the field ID as the search key is recommended for checkboxes. $search_criteria['field_filters'][] = array('key' => '2', 'value' => 'gquiz246fec995'); $search_criteria['field_filters'][] = array('key' => '2', 'operator' => 'in', 'value' => array( 'First Choice', 'Third Choice' ); NOTE: Neither 'not in' nor '<>' operators are not currently supported for checkboxes using field IDs as search keys.

Filter by a global search of values of any form field $search_criteria['field_filters'][] = array('value' => $search_value); OR $search_criteria['field_filters'][] = array('key' => 0, 'value' => $search_value);

Filter entries by Entry meta (added using the gform_entry_meta hook) $search_criteria['field_filters'][] = array('key' => 'gquiz_score', 'value' => '1'); $search_criteria['field_filters'][] = array('key' => 'gquiz_is_pass', 'value' => '1');

Filter by ALL / ANY of the field filters $search_criteria['field_filters']['mode'] = 'all'; // default $search_criteria['field_filters']['mode'] = 'any';

Sorting: column, field or entry meta $sorting = array('key' => $sort_field, 'direction' => 'ASC' );

Paging $paging = array('offset' => 0, 'page_size' => 20 );

Parameters

NameTypeDefaultDescription
$form_idsint | arrayThe ID of the form or an array IDs of the Forms. Zero for all forms.
$search_criteriaarray[]Optional. An array containing the search criteria. Defaults to empty array.
$sortingarraynullOptional. An array containing the sorting criteria. Defaults to null.
$pagingarraynullOptional. An array containing the paging criteria. Defaults to null.
&$total_countintnullOptional. An output parameter containing the total number of entries. Pass a non-null value to get the total count. Defaults to null.

Returns

  • array | WP_Error — Either an array of the Entry objects or a WP_Error instance.

Since: 1.8

Source: includes/api.php:625

get_entry_ids()

public static function get_entry_ids( $form_id, $search_criteria=[], $sorting=null, $paging=null, &$total_count=null )

Returns an array of Entry IDs for the given search criteria.

Parameters

NameTypeDefaultDescription
$form_idint | arrayThe ID of the form or an array IDs of the Forms. Zero for all forms.
$search_criteriaarray[]Optional. An array containing the search criteria. Defaults to empty array.
$sortingarraynullOptional. An array containing the sorting criteria. Defaults to null.
$pagingarraynullOptional. An array containing the paging criteria. Defaults to null.
&$total_countnull | intnullOptional. An output parameter containing the total number of entries. Pass a non-null value to get the total count. Defaults to null.

Returns

  • array — An array of the Entry IDs.

Since:

  • 2.3 (Added $sorting and $paging parameters.)
  • Unknown

Source: includes/api.php:661

count_entries()

public static function count_entries( $form_ids, $search_criteria=[] )

Returns the total number of entries for the given search criteria. See get_entries() for examples of the search criteria.

Parameters

NameTypeDefaultDescription
$form_idsint | arrayThe ID of the Form or an array of Form IDs.
$search_criteriaarray[]Optional. An array containing the search criteria. Defaults to empty array.

Returns

  • int — The total count.

Since: 1.8

Source: includes/api.php:691

get_entry()

public static function get_entry( $entry_id )

Returns the Entry object for a given Entry ID.

Parameters

NameTypeDefaultDescription
$entry_idintThe ID of the Entry.

Returns

  • array | WP_Error — The Entry object or a WP_Error instance.

Since: 1.8

Source: includes/api.php:714

add_entries()

public static function add_entries( $entries, $form_id=null )

Adds multiple Entry objects.

Parameters

NameTypeDefaultDescription
$entriesarrayThe Entry objects
$form_idintnullOptional. If specified, the form_id in the Entry objects will be ignored. Defaults to null.

Returns

  • array | WP_Error — Either an array of new Entry IDs or a WP_Error instance

Since: 1.8

Source: includes/api.php:752

update_entries()

public static function update_entries( $entries )

Updates multiple Entry objects.

Parameters

NameTypeDefaultDescription
$entriesarrayThe Entry objects

Returns

  • bool | WP_Error — Either true for success, or a WP_Error instance

Since: 1.8

Source: includes/api.php:786

update_entry()

public static function update_entry( $entry, $entry_id=null )

Updates an entire single Entry object.

If the date_created value is not set then the current time UTC will be used. The date_created value, if set, is expected to be in 'Y-m-d H:i:s' format (UTC).

Parameters

NameTypeDefaultDescription
$entryarrayThe Entry Object.
$entry_idintnullOptional. If specified, the ID in the Entry Object will be ignored. Defaults to null.

Returns

  • true | WP_Error — Either True or a WP_Error instance

Since: 1.8

Source: includes/api.php:835

add_entry()

public static function add_entry( $entry )

Adds a single Entry object.

Intended to be used for importing an entry object. The usual hooks that are triggered while saving entries are not fired here. Checks that the form id, field ids and entry meta exist and ignores legacy values (i.e. values for fields that no longer exist).

Parameters

NameTypeDefaultDescription
$entryarrayThe Entry Object.

Returns

  • int | WP_Error — Either the new Entry ID or a WP_Error instance.

Since: 1.8

Source: includes/api.php:1231

delete_entry()

public static function delete_entry( $entry_id )

Deletes a single Entry.

Parameters

NameTypeDefaultDescription
$entry_idintThe ID of the Entry object.

Returns

  • bool | WP_Error — Either true for success or a WP_Error instance.

Since: 1.8

Source: includes/api.php:1358

update_entry_property()

public static function update_entry_property( $entry_id, $property, $value )

Updates a single property of an entry.

Parameters

NameTypeDefaultDescription
$entry_idintThe ID of the Entry object.
$propertystringThe property of the Entry object to be updated.
$valuemixedThe value to which the property should be set.

Returns

  • int | false — The number of rows updated, or false on error or if there is a submissions block.

Since: 1.8.3.1

Source: includes/api.php:1387

update_entry_field()

public static function update_entry_field( $entry_id, $input_id, $value, $item_index='' )

Updates a single field of an entry.

Parameters

NameTypeDefaultDescription
$entry_idintThe ID of the Entry object.
$input_idstringThe id of the input to be updated. For single input fields such as text, paragraph, website, drop down etc... this will be the same as the field ID. For multi input fields such as name, address, checkboxes, etc... the input id will be in the format {FIELD_ID}.{INPUT NUMBER}. ( i.e. "1.3" ). The $input_id can be obtained by inspecting the key for the specified field in the $entry object.
$valuemixedThe value to which the field should be set.
$item_indexstring''The item index if the field is inside a Repeater.

Returns

  • bool | array — Whether the entry property was updated successfully. If there's an error getting the entry, the entry object.

Since: 1.9

Source: includes/api.php:1412

get_notes()

public static function get_notes( $search_criteria=[], $sorting=null )

Get notes based on search criteria.

Parameters

NameTypeDefaultDescription
$search_criteriaarray[]Array of search criteria.
$sortingarraynullSort key and direction.

Returns

  • array | bool

Since: 2.4.18

Source: includes/api.php:1485

get_note()

public static function get_note( $note_id )

Get note by ID.

Parameters

NameTypeDefaultDescription
$note_idintID of the note to retrieve.

Returns

Since: 2.4.18

Source: includes/api.php:1512

add_note()

public static function add_note( $entry_id, $user_id, $user_name, $note, $note_type='user', $sub_type=null )

Create one note for an entry.

Parameters

NameTypeDefaultDescription
$entry_idintID of the entry to add the note to.
$user_idintID of the user to associate with the note.
$user_namestringName of the user to associate with the note.
$notestringText of the note.
$note_typestring'user'Note type.
$sub_typenullnullNot sub-type.

Returns

Since: 2.4.18

Source: includes/api.php:1535

delete_note()

public static function delete_note( $note_id )

Delete one note.

Parameters

NameTypeDefaultDescription
$note_idintID of the note to delete.

Returns

  • int | WP_Error — ID of the deleted note.

Since: 2.4.18

Source: includes/api.php:1561

update_note()

public static function update_note( $note, $note_id='' )

Update a note.

Parameters

NameTypeDefaultDescription
$notearray{ Note data to update.
$note_idint''ID of the note to update.

Returns

Since: 2.4.18

Source: includes/api.php:1590

submit_form()

public static function submit_form( $form_id, $input_values, $field_values=[], $target_page=0, $source_page=1, $initiated_by=null )

Submits a form. Use this function to send input values through the complete form submission process.

Supports field validation, notifications, confirmations, multiple-pages and save & continue.

Example usage: $input_values['input_1'] = 'Single line text'; $input_values['input_2_3'] = 'First name'; $input_values['input_2_6'] = 'Last name'; $input_values['input_5'] = 'A paragraph of text.'; //$input_values['gform_save'] = true; // support for save and continue

$result = GFAPI::submit_form( 52, $input_values );

Example output for a successful submission: 'is_valid' => boolean true 'page_number' => int 0 'source_page_number' => int 1 'confirmation_message' => string 'confirmation message [snip]'

Example output for failed validation: 'is_valid' => boolean false 'validation_messages' => array (size=1) 2 => string 'This field is required. Please enter the first and last name.' 'page_number' => int 1 'source_page_number' => int 1 'confirmation_message' => string ''

Example output for save and continue: 'is_valid' => boolean true 'page_number' => int 1 'source_page_number' => int 1 'confirmation_message' => string 'Please use the following link to return to your form from any computer. [snip]' 'resume_token' => string '045f941cc4c04d479556bab1db6d3495'

Parameters

NameTypeDefaultDescription
$form_idintThe Form ID
$input_valuesarrayAn array of values. Not $_POST, that will be automatically merged with the $input_values.
$field_valuesarray[]Optional. An array of dynamic population parameter keys with their corresponding values used to populate the fields.
$target_pageint0Optional. For multi-page forms to indicate which page is to be loaded if the current page passes validation. Default is 0, indicating the last or only page is being submitted.
$source_pageint1Optional. For multi-page forms to indicate which page of the form was just submitted. Default is 1.
$initiated_bynull | intnullOptional. The process that initiated the submission. Supported integers are 1 (aka GFFormDisplay::SUBMISSION_INITIATED_BY_WEBFORM) or 2 (aka GFFormDisplay::SUBMISSION_INITIATED_BY_API). Defaults to GFFormDisplay::SUBMISSION_INITIATED_BY_API.

Returns

  • array | WP_Error — An array containing the result of the submission.

Since:

  • Unknown
  • 2.9.9 (Added the optional $initiated_by param.)

Source: includes/api.php:1691

validate_form()

public static function validate_form( $form_id, $input_values=[], $field_values=[], $target_page=0, $source_page=1 )

Validates the field values.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form this submission belongs to.
$input_valuesarray[]Optional. An associative array containing the values to be validated using the field input names as the keys. Will be merged into the $_POST.
$field_valuesarray[]Optional. An array of dynamic population parameter keys with their corresponding values used to populate the fields. Overwrites $_POST['gform_field_values'].
$target_pageint0Optional. For multi-page forms; indicates which page would be loaded next if the current page passes validation. Overwrites $_POST[ 'gform_target_page_number_' . $form_id ].
$source_pageint1Optional. For multi-page forms; indicates which page was active when the values were submitted for validation. Overwrites $_POST[ 'gform_source_page_number_' . $form_id ].

Returns

Since: 2.6.4

Source: includes/api.php:1798

validate_field()

public static function validate_field( $form_id, $field_id, $input_values=[] )

Validates the submitted value of the specified field.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form this submission belongs to.
$field_idintThe ID of the field to be validated.
$input_valuesarray[]Optional. An associative array containing the values to be validated using the field input names as the keys. Will be merged into the $_POST.

Returns

Since:

  • 2.7
  • 2.8.7 (Added the gform_pre_validation filter.)

Source: includes/api.php:1866

submit_form_filter_gform_pre_validation()

public static function submit_form_filter_gform_pre_validation( $form )

Ensure that the state field is set when the form is submitted via GFAPI::submit_form()

or via the POST forms/[id]/submissions REST API endpoint.

Parameters

NameTypeDefaultDescription
$formarray

Returns

  • array

Since: 2.4.11

Source: includes/api.php:2003

get_feeds()

public static function get_feeds( $feed_ids=null, $form_ids=null, $addon_slug=null, $is_active=true )

Returns all the feeds for the given criteria.

Parameters

NameTypeDefaultDescription
$feed_idsmixednullThe ID of the Feed or an array of Feed IDs.
$form_idsnull | int | int[]nullThe ID of the Form to which the Feeds belong or array of Form IDs.
$addon_slugnull | stringnullThe slug of the add-on to which the Feeds belong.
$is_activebool | nulltrueIndicates if only active or inactive feeds should be returned. Use null to return both.

Returns

  • array | WP_Error — Either an array of Feed objects or a WP_Error instance.

Since:

  • 1.8
  • 2.4.24 (Updated $is_active to support using null to return both active and inactive feeds.)
  • 2.6.1 (Updated $form_ids to support an array of IDs.)
  • 2.7.17 (Added support for decrypting settings fields.)

Source: includes/api.php:2030

encrypt_feed_meta()

public static function encrypt_feed_meta( $feed_meta, $addon_slug )

Encrypts feed meta fields based on feed settings fields configuratino and returns the resulting feed meta array.

Parameters

NameTypeDefaultDescription
$feed_metaarrayThe feed meta array to encrypt.
$addon_slugstringThe slug of the add-on to which the feed belongs.

Returns

  • array — Returns the feed meta arra with the fields that should be encrypted.

Since: 2.7.17

Source: includes/api.php:2093

get_encryptor()

public static function get_encryptor()

Gets the encryption service object.

Returns

Since: 2.7.17

Source: includes/api.php:2120

set_encryptor()

public static function set_encryptor( $encryptor )

Sets the encryption service object to be used by GFAPI

Parameters

NameTypeDefaultDescription
$encryptorGravity_Forms\Gravity_Forms\Settings\GF_Settings_EncryptionThe encryption service object to be used.

Returns

  • void

Since: 2.7.17

Source: includes/api.php:2138

get_feed()

public static function get_feed( $feed_id )

Returns a specific feed.

Parameters

NameTypeDefaultDescription
$feed_idintThe ID of the feed to retrieve.

Returns

Since: 2.4.24

Source: includes/api.php:2151

delete_feed()

public static function delete_feed( $feed_id )

Deletes a single Feed.

Parameters

NameTypeDefaultDescription
$feed_idintThe ID of the Feed to delete.

Returns

  • bool | WP_Error — True if successful, or a WP_Error instance.

Since: 1.8

Source: includes/api.php:2171

update_feed()

public static function update_feed( $feed_id, $feed_meta, $form_id=null )

Updates a feed.

Parameters

NameTypeDefaultDescription
$feed_idintThe ID of the feed being updated.
$feed_metaarrayThe feed meta to replace the existing feed meta.
$form_idnullnullThe ID of the form that the feed is associated with

Returns

  • int | WP_Error — The number of rows updated or a WP_Error instance

Since:

  • Unknown
  • 2.7.17 (Added support for encrypting settings fields.)

Source: includes/api.php:2210

add_feed()

public static function add_feed( $form_id, $feed_meta, $addon_slug )

Adds a feed with the given Feed object.

Parameters

NameTypeDefaultDescription
$form_idintThe ID of the form to which the feed belongs.
$feed_metaarrayThe Feed Object.
$addon_slugstringThe slug of the add-on to which the feeds belong.

Returns

  • int | WP_Error — Either the ID of the newly created feed or a WP_Error instance.

Since:

  • 1.8
  • 2.7.17 (Added support for encrypting settings fields.)

Source: includes/api.php:2257

update_feed_property()

public static function update_feed_property( $feed_id, $property_name, $property_value )

Updates the specified feed with the given property value.

Parameters

NameTypeDefaultDescription
$feed_idintThe ID of the feed being updated.
$property_namestringThe name of the property (column) being updated.
$property_valuemixedThe new value of the specified property.

Returns

Since: 2.4.24

Source: includes/api.php:2311

maybe_process_feeds()

public static function maybe_process_feeds( $entry, $form, $addon_slug='', $reset_meta=false, $bypass_feed_delay=false )

Triggers processing of non-payment add-on feeds for the given entry.

Parameters

NameTypeDefaultDescription
$entryarrayThe entry to be processed.
$formarrayThe form the entry belongs to.
$addon_slugstring''A specific add-on slug, or an empty string for all non-payment add-on feeds to be processed.
$reset_metaboolfalseIndicates if the processed feeds meta for the entry should be reset.
$bypass_feed_delayfalse

Returns

  • false | array

Since: 2.9.2

Source: includes/api.php:2340

get_processed_feeds_meta()

public static function get_processed_feeds_meta( $entry_id, $addon_slug='' )

Returns the processed feeds meta for the specified entry.

Parameters

NameTypeDefaultDescription
$entry_idintThe ID of the entry the meta is to be retrieved for.
$addon_slugstring''An 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

  • array

Since: 2.9.2

Source: includes/api.php:2389

update_processed_feeds_meta()

public static function update_processed_feeds_meta( $entry_id, $addon_slug, $value, $form_id=null )

Updates or deletes the processed feeds meta for the specified entry.

Parameters

NameTypeDefaultDescription
$entry_idintThe ID of the entry the meta is to be updated for.
$addon_slugstringAn add-on slug when updating the meta for a specific add-on or an empty string to update the meta for all add-ons.
$valueint | array | nullThe 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_idnull | intnullThe form ID of the entry (optional, saves extra query if passed when creating the metadata).

Returns

  • void

Since: 2.9.2

Source: includes/api.php:2411

get_entry_feed_status_key()

public static function get_entry_feed_status_key( $feed_id )

Returns the key used when saving/retrieving the feed status entry meta.

Parameters

NameTypeDefaultDescription
$feed_idintThe feed ID.

Returns

  • string

Since: 2.9.4

Source: includes/api.php:2449

get_entry_feed_status()

public static function get_entry_feed_status( $entry_id, $feed_id, $return_latest=false, $return_latest_details=false )

Retrieves the feed processing status for the specified entry from the "feed_{$feed_id}_status" meta.

Parameters

NameTypeDefaultDescription
$entry_idintThe entry ID.
$feed_idintThe feed ID.
$return_latestboolfalseIndicates if only the latest attempt should be returned. Default is to return all attempts.
$return_latest_detailsboolfalseIndicates if the details array of the latest attempt should be returned instead of just the status string.

Returns

  • array | string

Since: 2.9.4

Source: includes/api.php:2465

update_entry_feed_status()

public static function update_entry_feed_status( $entry_id, $feed_id, $status, $form_id=null )

Updates or deletes the "feed_{$feed_id}_status" meta for the specified entry.

Parameters

NameTypeDefaultDescription
$entry_idintThe entry ID.
$feed_idintThe feed ID.
$statusarray | null{ The status array to be appended to the metadata or null to delete the metadata.
$form_idnull | intnullThe form ID of the entry (optional, saves extra query if passed when creating the metadata).

Returns

  • void

Since: 2.9.4

Source: includes/api.php:2500

get_feed_name()

public static function get_feed_name( $feed, $key='' )

Retrieves the name of the given feed.

Parameters

NameTypeDefaultDescription
$feedarrayThe feed.
$keystring''Optional. The key used to store the name.

Returns

  • string

Since: 2.9.9

Source: includes/api.php:2524

send_notifications()

public static function send_notifications( $form, $entry, $event='form_submission', $data=[] )

Triggers sending of active notifications for the given form, entry, and event.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object associated with the notification.
$entryarrayThe Entry Object associated with the triggered event.
$eventstring'form_submission'Optional. The event that's firing the notification. Defaults to 'form_submission'.
$dataarray[]Optional. Array of data which can be used in the notifications via the generic {object:property} merge tag. Defaults to empty array.

Returns

  • array

Since:

  • Unknown
  • 2.6.9 (Added support for async processing of notifications.)

Source: includes/api.php:2547

send_notification()

public static function send_notification( $notification, $form, $entry, $data=[] )

Triggers sending of the given notification.

Parameters

NameTypeDefaultDescription
$notificationarrayThe notification to be sent.
$formarrayThe form the notification belongs to.
$entryarrayThe entry the notification is being sent for.
$dataarray[]Optional. Array of data which can be used in the notifications via the generic {object:property} merge tag. Defaults to empty array.

Returns

  • void

Since: 2.10.0

Source: includes/api.php:2627

current_user_can_any()

public static function current_user_can_any( $capabilities )

Checks the permissions for the current user. Returns true if the current user has any of the specified capabilities.

IMPORTANT: Call this before calling any of the other API Functions as permission checks are not performed at lower levels.

Parameters

NameTypeDefaultDescription
$capabilitiesarray | stringAn array of capabilities, or a single capability

Returns

  • bool — Returns true if the current user has any of the specified capabilities

Since: 1.8.5.10

Source: includes/api.php:2683

get_fields_by_type()

public static function get_fields_by_type( $form, $types, $use_input_type=false )

Returns an array containing the form fields of the specified type or types.

Parameters

NameTypeDefaultDescription
$formarrayThe Form Object.
$typesarray | stringThe field types to get. Multiple field types as an array or a single type in a string.
$use_input_typeboolfalseOptional. Defaults to false.

Returns

Since: 1.9.9.8

Source: includes/api.php:2703

get_field()

public static function get_field( $form_or_id, $field_id )

Returns the field object for the requested field or input ID from the supplied or specified form.

Parameters

NameTypeDefaultDescription
$form_or_idarray | intThe Form Object or ID.
$field_idstring | intThe field or input ID.

Returns

Since: 2.3

Source: includes/api.php:2720

form_id_exists()

public static function form_id_exists( $form_id )

Checks whether a form ID exists.

Parameters

NameTypeDefaultDescription
$form_id

Since:

  • 1.8
  • 2.4.24 (Updated to use GFFormsModel::id_exists_in_table().)

Source: includes/api.php:2734

entry_exists()

public static function entry_exists( $entry_id )

Checks if an entry exists for the supplied ID.

Parameters

NameTypeDefaultDescription
$entry_idintThe ID to be checked.

Returns

  • bool

Since: 2.4.6

Source: includes/api.php:2747

feed_exists()

public static function feed_exists( $feed_id )

Checks if a feed exists for the supplied ID.

Parameters

NameTypeDefaultDescription
$feed_idintThe ID to be checked.

Returns

  • bool

Since: 2.4.24

Source: includes/api.php:2760

log_error()

public static function log_error( $message )

Write an error message to the Gravity Forms API log.

Parameters

NameTypeDefaultDescription
$messagestringThe message to be logged.

Since: 2.4.11

Source: includes/api.php:2771

log_debug()

public static function log_debug( $message )

Write a debug message to the Gravity Forms API log.

Parameters

NameTypeDefaultDescription
$messagestringThe message to be logged.

Since: 2.4.11

Source: includes/api.php:2785

unique_title()

public static function unique_title( $title, $form_id='' )

Make sure the form title is unique.

Parameters

NameTypeDefaultDescription
$titlestring
$form_idint | string''

Returns

  • string

Since: 2.5

Source: includes/api.php:2802