gform_webhooks_post_request

Description

The “gform_webhooks_post_request” action fires after a Webhooks request has been executed and allows further actions to be performed.

Usage

The following would apply to 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.

Examples

Delete entry after successful WordPress response for Webhook processing

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

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

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in GF_Webhooks::process_feed() in gravityformswebhooks/class-gf-webhooks.php.