Entry Object

Entry Object

IntroductionUsagePropertiesStandardPricing PropertiesPost CreationField ValuesList FieldCheckboxes FieldAdd-On Field ValuesEntry JSON

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.
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

Properties

Standard

id integer
The entry』s Id.

form_id string
The ID of the form from which the entry was submitted.

created_by integer
ID of the user that submitted the form if a logged in user submitted the form.

date_created string
The date and time that the entry was created, in the format 「yyyy-mm-dd hh:mi:ss」 (i.e. 2010-07-15 17:26:58)

is_starred bool
Indicates if the entry has been starred (i.e marked with a star). 1 for entries that are starred and 0 for entries that are not starred.

is_read bool
Indicates if the entry has been read. 1 for entries that are read and 0 for entries that have not been read.

ip string
Client IP of user who submitted the form.

source_url string
Source URL of page that contained the form when it was submitted.

post_id integer
For forms with Post fields, this property contains the Id of the Post that was created.

user_agent string
Provides the name and version of both the browser and operating system from which the entry was submitted.

status string
The current status of the entry (ie 「Active」, 「Spam」, 「Trash」).

Pricing Properties
These $entry properties are only relevant when a Gravity Forms payment gateway add-on is being used.

currency string
The currency with which the entry was submitted (ie 「USD」, 「EUR」).

payment_status string
The current payment status of the entry (ie 「Authorized」, 「Paid」, 「Processing」, 「Pending」, 「Active」, 「Expired」, 「Failed」, 「Cancelled」, 「Approved」, 「Reversed」, 「Refunded」, 「Voided」).

payment_date string
The date the payment has been received.

payment_amount integer
The amount of the fulfilled payment; this property is empty until the payment has been received. Sample value: 75

transaction_id string
ID of the transaction returned by the payment gateway

is_fulfilled bool
Indicates if the entry/order has been fulfilled. 1 for entries that have been fulfilled and 0 for entries that have not been fulfilled.

transaction_type integer
Indicates the transaction type of the entry/order. 1 for one time payments, 2 for subscriptions.

Post Creation
The following property is only relevant when the form is used to create a WordPress post.

post_id integer
The id number of the post created as result of the form submission.

Field Values

FIELD_ID string
The value for all submitted fields can be retrieved by using the Field Id as the key to the $entry array.
rgar( $entry, '1' ); // returns the value associated with field 1
rgar( $entry, '2.4' ); // returns the value associated with the state input for the address field 2

List Field
The List field type due to its complex setup compared to other field types (it has many rows and columns of data) it』s stored in serialized format, so you need to unserialize it first to access the data.
maybe_unserialize( rgar( $entry, '3' ) ); // unserialize values associated with list field 3

Checkboxes Field
The easiest way to get the checked checkboxes would be to get a comma separated string containing the selected choices without accessing each input in the entry and building the string yourself would be to use the get_value_export method of the field object, here』s an example
$field_id = 18; // Update this number to your field id number
$field = RGFormsModel::get_field( $form, $field_id );
$value = is_object( $field ) ? $field->get_value_export( $entry ) : '';

That would return a comma separated list containing the values for the selected choices, if you wanted to use the choice text then you would use the following
$value = is_object( $field ) ? $field->get_value_export( $entry, $field_id, true ) : '';

You can then convert that comma separate list to an array, if you want, 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:

Coupon
Dropbox Upload

Entry JSON
This example shows how an entry array would look when formatted as JSON for use by the Gravity Forms CLI Add-On.
{
"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",
"1":"Third Choice",
"2":"This is text content"
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注