# Gform\_after\_submission

**URL:** <https://community.gravityforms.com/t/gform-after-submission/9818>\
**Category:** Get Help\
**Tags:** gform\_after\_submission\
**Created:** [June 14, 2021, 11:28pm UTC](https://community.gravityforms.com/t/gform-after-submission/9818 "2021-06-14T23:28:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Operator95](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@Operator95](https://community.gravityforms.com/u/Operator95)\
**Post date:** [June 14, 2021, 11:28pm UTC](https://community.gravityforms.com/t/gform-after-submission/9818/1 "2021-06-14T23:28:07Z")

</div>

I’m testing gform\_after\_submission. [Docs say](https://docs.gravityforms.com/gform_after_submission/) I should have the Entry object and Form object.

I am able to access the Entry object, but having trouble getting the form. Any ideas or tips?

---

<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:** [June 15, 2021, 4:06am UTC](https://community.gravityforms.com/t/gform-after-submission/9818/2 "2021-06-15T04:06:30Z")

</div>

Let’s see your code. Use a code sharing site, and share the link here. Include the add\_filter line as well as your function. We can help figure out what is wrong or help you with some additional debugging.

---

<div class="post-metadata">

**Author:** ![Operator95](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@Operator95](https://community.gravityforms.com/u/Operator95)\
**Post date:** [June 15, 2021, 4:30am UTC](https://community.gravityforms.com/t/gform-after-submission/9818/3 "2021-06-15T04:30:59Z")

</div>

Thanks so much, Chris.

Here’s a link to [pastie](http://pastie.org/p/0gXrpcItnzdtk4N71ZvyxG).

The table ‘option’ is one I created, and my rpw\_insert\_option function is working fine for anything else I have sent to it.

If I just send **$entry** , it works fine. But with both **( $entry, $action )**, nothing happens. If I just send $action, nothing happens.

I’ve also tried this with gform\_post\_payment\_completed to no avail.

The original goal here was to insert data from the **$Form** object and **$Entry** object after a payment succeeds.

---

<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:** [June 15, 2021, 3:28pm UTC](https://community.gravityforms.com/t/gform-after-submission/9818/4 "2021-06-15T15:28:00Z")

</div>

Hello. The function has two arguments: `$entry` and `$form`. It should be defined like this:

```auto
function rpw_update_room_sold( $entry, $form ) {

```

The second argument should be `$form`, not `$action`. You will need to define your function in this way to have access to the `$form` object. If you need your `$action` somewhere, you will need to get it into the function in some other way.

---

<div class="post-metadata">

**Author:** ![Operator95](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@Operator95](https://community.gravityforms.com/u/Operator95)\
**Post date:** [June 16, 2021, 8:21am UTC](https://community.gravityforms.com/t/gform-after-submission/9818/5 "2021-06-16T08:21:03Z")

</div>

I will give that a try, thank you very much.

---

<div class="post-metadata">

**Author:** ![katzwebservices](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/katzwebservices/32/976_2.png) [@katzwebservices](https://community.gravityforms.com/u/katzwebservices)\
**Post date:** [June 18, 2021, 1:20pm UTC](https://community.gravityforms.com/t/gform-after-submission/9818/6 "2021-06-18T13:20:26Z")

</div>

Also, when you add the hook, make sure you set the `$accepted_args` to `2`. See the two at the end here:

`add_action( 'gform_after_submission', 'rpw_update_room_sold', 10, 2 );`

> **[add\_action() | Function | WordPress Developer Resources](https://developer.wordpress.org/reference/functions/add_action/)**
>
> Hooks a function on to a specific action.

---

<div class="post-metadata">

**Author:** ![Operator95](https://avatars.discourse-cdn.com/v4/letter/o/9de0a6/32.png) [@Operator95](https://community.gravityforms.com/u/Operator95)\
**Post date:** [June 22, 2021, 4:13am UTC](https://community.gravityforms.com/t/gform-after-submission/9818/7 "2021-06-22T04:13:58Z")

</div>

Thanks, Zack!!

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [January 5, 2022, 8:31am UTC](https://community.gravityforms.com/t/gform-after-submission/9818/8 "2022-01-05T08:31:44Z")

</div>

Closed on January 5, 2022, 8:31am UTC


