This must be simpler than I think, but I can’t figure it out. I want to run a php function that just needs the entry_id of the form that was submitted. How do I call the function to pass that entry_id to it when the form submits?
Hi Dottie,
It looks like you’re trying to use the gform_after_submission_146 hook to run your set_post_content function after submitting a Gravity Form with an ID of 146. The gform_after_submission_146 hook passes two arguments to the function it runs: the $entry array, which contains information about the form submission, and the $form array, which contains information about the form itself.
To access the entry ID of the form submission, you can use the entry_id key of the $entry array. Here’s an example of how you could use it in your function:
[26-Dec-2022 17:24:10 UTC] PHP Warning: Undefined array key “entry_id” in /chroot/home/ac2062f0/8b1f145e25.nxcli.net/html/wp-content/themes/astra/functions.php on line 206
line 206: is the line function set_post_content( $entry, $form )
That didn’t work, either. I must need some other action. I will try a different way to get what I need as I can’t figure out how to get the form’s entry_id.
It looks like the $entry array does not contain an entry_id key. This could be because the gform_after_submission_146 hook is not running or because the $entry array is not being passed to the hook correctly.
Here are a few things you can try to troubleshoot the issue:
Make sure that the Gravity Form with an ID of 146 is active and configured correctly on your WordPress site.
Check the error log to see if there are any other error messages that might give you more information about the issue.
Make sure your set_post_content function is registered correctly with the gform_after_submission_146 hook. You can do this by adding some debug code to your function like this:
Then, check your error log to see if the set_post_content function called message is being logged when the form is submitted. If it is not, the hook is not running, and you will need to investigate why.
Make sure that the $entry array contains the data you expect it to. You can do this by adding some debug code to your function like this: