# Getting entry fields from gravity form

**URL:** <https://community.gravityforms.com/t/getting-entry-fields-from-gravity-form/10772>\
**Category:** Get Help\
**Tags:** custom, gform\_after\_submission\
**Created:** [September 22, 2021, 1:44am UTC](https://community.gravityforms.com/t/getting-entry-fields-from-gravity-form/10772 "2021-09-22T01:44:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![user614312f064afe021](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user614312f064afe021/32/3615_2.png) [@user614312f064afe021](https://community.gravityforms.com/u/user614312f064afe021)\
**Post date:** [September 22, 2021, 1:44am UTC](https://community.gravityforms.com/t/getting-entry-fields-from-gravity-form/10772/1 "2021-09-22T01:44:48Z")

</div>

I am working on using Gravity Forms to submit to a third party API. I have been reading the documentation for gform\_after\_submission and I can’t figure out how to refer to the fields in my form when I submit the values that are in the form. I am seeing things like this:

```auto
$body = array(
    'brand' => $entry['20'],
    'product' => $entry['22'],
    'form_id' => $entry['21'],
    'title' => $entry['24'],
    'fname' => $entry['23'],
    'lname' => $entry['17'],
    'postcode' => $entry['14'],
    'address1' => $entry['2.1'],
    'address2' => $entry['2.2'],
    'town' => $entry['2.3'],
    'county' => $entry['2.4']   
    );

```

However, I have no idea where they get what the entry is on the Gravity form I created. I appreciate any help I can get in this.

Jerry

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [September 22, 2021, 5:05pm UTC](https://community.gravityforms.com/t/getting-entry-fields-from-gravity-form/10772/2 "2021-09-22T17:05:31Z")

</div>

Hi Jerry. gform\_after\_submission can be applied to all forms or individual forms. When you apply it to an individual form like this:

`add_action( 'gform_after_submission_93', 'send_to_api', 10, 2 );`

That means when form 93 is submitted, this hooks runs, and you have an `$entry` you can access, like this:

```auto
add_action( 'gform_after_submission_93', 'send_to_api', 10, 2 );
function send_to_api( $entry, $form ) {
	// take what was submitted in field 21 of the entry and
	// assign it to $some_variable
	$some_variable = rgar ( $entry, '21' );
	// do something with that variable
}

```

I used the helper function `rgar` to access to `$entry`:

> **[rgar()](https://docs.gravityforms.com/rgar/)**
>
> This Gravity Forms function returns a value within an array based on providing a reference to an array and a key for that array.

Does that make sense? Because gform\_after\_submission runs after every form submission (of submissions for a specific form if you limit it like I did) you will have a single `$entry` where you can find all the information that was submitted in the form.

Let me know if you have any other questions.

---

<div class="post-metadata">

**Author:** ![user614312f064afe021](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/user614312f064afe021/32/3615_2.png) [@user614312f064afe021](https://community.gravityforms.com/u/user614312f064afe021)\
**Post date:** [September 23, 2021, 2:19am UTC](https://community.gravityforms.com/t/getting-entry-fields-from-gravity-form/10772/3 "2021-09-23T02:19:25Z")

</div>

It does make sense. And helps a lot. Where I am stuck is how would I use the JSON file I have with those form IDs. That documentation helps but not with nested JSON. I’ve almost wanted to see if I can use the enqueue and then when the form submits I use Javascript since that is what I am more familiar with. But getting the IDs of each of the form elements to stay the same would be tricky.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [October 1, 2021, 8:48pm UTC](https://community.gravityforms.com/t/getting-entry-fields-from-gravity-form/10772/4 "2021-10-01T20:48:11Z")

</div>

Closed on October 1, 2021, 8:48pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
