Using Gravity Forms ‘gform_webhooks_post_request’ PHP action

The gform_webhooks_post_request action fires after a Webhooks request has been executed, allowing for additional actions to be performed.

Usage

A generic example for all forms:

add_action('gform_webhooks_post_request', 'your_function_name', 10, 4);

To target a specific form, append the form ID to the hook name (format: gform_webhooks_post_request_FORMID):

add_action('gform_webhooks_post_request_78', 'your_function_name', 10, 4);

To target a specific form’s feed, append the form ID and feed ID to the hook name (format: gform_webhooks_post_request_FORMID_FEEDID):

add_action('gform_webhooks_post_request_78_12', 'your_function_name', 10, 4);

Parameters

  • $response: WP_Error or array – The response from the request execution. The response will be the WP_Error object if the execution fails, otherwise an array.
  • $feed: Feed Object – The feed object.
  • $entry: Entry Object – The current entry.
  • $form: Form Object – The form object.

More information

See Gravity Forms Docs: gform_webhooks_post_request

Source code for this action is located in GF_Webhooks::process_feed() in gravityformswebhooks/class-gf-webhooks.php.

Examples

Delete entry after successful WordPress response for Webhook processing

This example deletes the entry after a successful Webhooks request.

add_action('gform_webhooks_post_request', function ($response, $feed, $entry, $form) {
    if (!is_wp_error($response)) {
        GFAPI::delete_entry($entry['id']);
    }
}, 10, 4);

Send an email if WordPress returns an error for Webhook processing

This example sends an email when a Webhooks request returns an error.

add_action('gform_webhooks_post_request', function ($response, $feed, $entry, $form) {
    if (is_wp_error($response)) {
        $to      = '[email protected]'; // Change this to your email address.
        $subject = 'Webhook failed!';
        $body    = "Webhook for entry #$entry[id] failed.";
        wp_mail($to, $subject, $body);
    }
}, 10, 4);