Updating Entries with the GFAPI

Introduction

The GFAPI::update_entry(), GFAPI::update_entries(), GFAPI::update_entry_property(), and GFAPI::update_entry_field() methods are used to update entries in the database.

Updating a single entry

The GFAPI::update_entry() method is used to update a single entry.

Source Code

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

This method is located in /includes/api.php.

Parameters

ParamTypeDescription
$entryarraySee Entry Object.
$entry_idnull|integerOptional.
The entry to be updated, overrides the $entry['id'].

Returns

Boolean, true on success, or a WP_Error instance if an error occurs.

Usage Example

$result = GFAPI::update_entry( $entry );

Updating multiple entries

The GFAPI::update_entries() method is used to update multiple entries.

Source Code

public static function update_entries( $entries ) {}

This method is located in /includes/api.php.

Parameters

ParamTypeDescription
$entriesarray[]An array containing the entries to be updated.
See Entry Object.

Returns

Boolean, true on success, or a WP_Error instance if an error occurs.

Usage Example

$result = GFAPI::update_entries( array( $entry_1, $entry_2 ) );

Updating an entry property

The GFAPI::update_entry_property() method is used to update a property of a single entry.

Source Code

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

This method is located in /includes/api.php.

Parameters

ParamTypeDescription
$entry_idintegerThe ID of the entry the property is to be updated for.
$propertystringThe name of the column in the database to be updated.
Possible values: form_id, post_id, date_created, date_updated, is_starred, is_read, ip, source_url, user_agent, currency, payment_status, payment_date, payment_amount, payment_method, transaction_id, is_fulfilled, created_by, transaction_type, or status
$valuenull|string|integer|floatThe new value of the property.

Returns

Boolean, the result of the update query.

Usage Example

$result = GFAPI::update_entry_property( $entry_id, $property, $value );

Updating an entry field value

The GFAPI::update_entry_field() method is used to update a field or input value of a single entry.

Source Code

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

This method is located in /includes/api.php.

Parameters

ParamTypeDescription
$entry_idintegerThe ID of the entry the field or input value is to be updated for.
$input_idinteger|stringThe ID of the field or input the value is to be updated for.
$valuenull|string|integer|floatThe new value of the field or input.
$item_indexstringThe item index if the field or input is a child of a Repeater field.

Returns

Boolean or a WP_Error instance if an error occurs.

Usage Example

$result = GFAPI::update_entry_field( $entry_id, $input_id, $value );