Introduction
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 that field’s data.
Properties
Prop | Type | Description |
---|---|---|
id | integer | The unique ID assigned to the entry by the database. |
form_id | integer | The ID of the form the entry was created by. |
created_by | null|integer | Null or the ID of the logged-in user who submitted the form. |
date_created | string | The UTC date and time the entry was created. Format: YYYY-MM-DD HH:MM:SS |
date_updated | string | The UTC date and time the entry was most recently updated. Format: YYYY-MM-DD HH:MM:SS |
is_starred | bool|integer | Indicates if the entry has been starred (i.e., marked with a star). true or 1 when starred.false or 0 when not starred. |
is_read | bool|integer | Indicates if the entry has been viewed.true or 1 when viewed.false or 0 when not viewed. |
ip | string | The IP address of the user who submitted the form. |
source_url | string | The URL of the request that saved the entry, limited to 200 characters. Usually, the URL of the page where the form is embedded. It can also contain the Admin Ajax or REST endpoint URL if the entry was created by an Ajax or REST API request. |
post_id | null|integer | Null or the ID of the post created by legacy post fields. This is not used by the Advanced Post Creation add-on. |
user_agent | string | The user agent string (limited to 250 characters) from the browser the user used to submit the form. Helps identify the browser, operating system, and device used to submit the form, but it can be unreliable. |
status | string | The current status of the entry. Possible values: active , spam , trash |
currency | string | The three character ISO 4217 currency code used by the submission for any pricing fields and payment add-ons. |
payment_status | null|string | Null or the status (limited to 15 characters) of the transaction processed by a payment add-on. Possible values: Authorized , Paid , Processing , Pending , Active , Expired , Failed , Cancelled , Approved , Reversed , Refunded , Voided , or a custom value set by a third-party add-on. |
payment_date | null|string | Null or the UTC date and time the transaction was processed. Format: YYYY-MM-DD HH:MM:SS |
payment_amount | null|integer|float | Null or the transaction amount without the currency symbol. |
transaction_id | null|string | Null or the ID of the transaction returned by the payment gateway. |
is_fulfilled | null|bool|integer | Indicates if the entry/order has been fulfilled.true or 1 when fulfilled.false or 0 when not fulfilled. |
transaction_type | null|integer | Indicates the transaction type of the entry/order.1 for a one-time payment (product/service type feed).2 for a subscription. |
source_id | null|integer | Null or the ID of the post or page where the form was embedded at the time the entry was saved. Since Gravity Forms 2.9. |
...[Field or Input ID] | mixed | Each field or input value is accessible in the entry using the field or input ID as the key to the value. |
...[Meta Key] | mixed | Add-ons can register additional meta, some of which is accessible in the entry using the meta key as the key to the value. |
Usage
rgar( $entry, 'date_created' ); // returns the entry date
rgar( $entry, '1' ); // returns the value associated with field 1 (This would be for fields with single input like Text, Number, Drop Down, etc...)
rgar( $entry, '1.3' ); // returns the value associated with the first name portion of a simple name field 1
rgar( $entry, '1.6' ); // returns the value associated with the last name portion of a simple name field 1
rgar( $entry, '2.4' ); // returns the value associated with the state input for the address field 2
rgar( $entry, '5.1' ); // returns the field label for a single product that has id 5
rgar( $entry, '5.1' ); // returns the field label for a single product that has id 5
GFCommon::to_number( rgar( $entry, '5.2' ) ); // returns the field price, without currency symbol, for a single product that has id 5
rgar( $entry, '5.3' ); // returns the field quantity for a single product that has id 5
List Field
Because the List field type has a complex structure with multiple rows and columns, it is stored in a serialized format. To work with its data, you must first unserialize the field.
maybe_unserialize( rgar( $entry, '3' ) ); // unserialize values associated with list field 3
Checkboxes Field
To easily obtain a comma-separated string of selected checkboxes without manually iterating through each input, use the get_value_export
method of the field object. For example:
$field_id = 18; // Update this number to your field id number
$field = GFAPI::get_field( $form_or_id, $field_id );
$value = is_object( $field ) ? $field->get_value_export( $entry ) : '';
The get_value_export
method returns a comma-separated list of the values for selected choices. If you want to retrieve the actual choice text instead, you’ll need to use a different approach.
$value = is_object( $field ) ? $field->get_value_export( $entry, $field_id, true ) : '';
You can easily convert the comma-separated list to an array using PHP’s explode() function.
Add-On Field Values
See the following pages for details about the entry values for fields added by add-ons:
Entry JSON
This example shows how an entry array would look when formatted as JSON for use by the Gravity Forms CLI Add-On.
{
"1": "Third Choice",
"2": "This is text content",
"id": "1",
"form_id": "1",
"date_created": "2016-03-22 19:13:19",
"is_starred": 0,
"is_read": 0,
"ip": "192.168.50.1",
"source_url": "http:\\/\\/local.wordpress.dev\\/?gf_page=preview&id=1",
"post_id": null,
"currency": "USD",
"payment_status": null,
"payment_date": null,
"transaction_id": null,
"payment_amount": null,
"payment_method": null,
"is_fulfilled": null,
"created_by": "1",
"transaction_type": null,
"user_agent": "Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/48.0.2564.116 Safari\\/537.36",
"status": "active"
}