I’m using the Gravity Forms Webhook addon to send form details to a third-party endpoint. The API will send back a response and depending on a value in the response header I’d like to show a message to a user. I’m looking for the following:
Confirmation if this function is the right function to use gfrom_webhooks_post_request to get the response? How I should go about getting the headers in the response?
So they don’t impact form submission performance, most add-on feeds, including webhooks, are processed via a separate background request. For this reason, the webhook response is not available out of the box when the form confirmation is displayed to the submitter.
You could use the gform_is_feed_asynchronous filter to disable background processing for the add-on, so its feeds will be processed before the confirmation is displayed.
The gfrom_webhooks_post_request hook is the correct hook to use to access the webhook response headers. You can do that like so:
If you want to display values from the response headers on the confirmation, you’ll need to stash them somewhere that can also accessed when the confirmation is being prepared. You could save them as custom entry meta, e.g.