Using Gravity Forms ‘gform_webhooks_request_method’ PHP filter

The gform_webhooks_request_method filter allows you to modify the webhook HTTP request method in Gravity Forms.

Usage

To apply this filter to all forms, use the following code:

add_filter('gform_webhooks_request_method', 'your_function_name', 10, 4);

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

add_filter('gform_webhooks_request_method_7', 'your_function_name', 10, 4);

Parameters

  • $request_method (string): The HTTP request method.
  • $feed (Feed Object): The current feed object.
  • $entry (Entry Object): The current entry object.
  • $form (Form Object): The current form object.

More information

See Gravity Forms Docs: gform_webhooks_request_method

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

Examples

Change request method to GET

This example changes the webhook HTTP request method to GET.

add_filter('gform_webhooks_request_method', 'set_method', 10, 4);

function set_method($request_method, $feed, $entry, $form) {
    return 'GET';
}

Change request method to PUT for form 7

This example changes the webhook HTTP request method to PUT for form with ID 7.

add_filter('gform_webhooks_request_method_7', 'set_put_method', 10, 4);

function set_put_method($request_method, $feed, $entry, $form) {
    return 'PUT';
}

Change request method based on entry value

This example changes the webhook HTTP request method based on a specific entry value.

add_filter('gform_webhooks_request_method', 'change_method_based_on_entry', 10, 4);

function change_method_based_on_entry($request_method, $feed, $entry, $form) {
    if ($entry['1'] == 'GET') {
        return 'GET';
    } else {
        return 'POST';
    }
}

Change request method based on form title

This example changes the webhook HTTP request method to PUT for forms with a specific title.

add_filter('gform_webhooks_request_method', 'change_method_based_on_form_title', 10, 4);

function change_method_based_on_form_title($request_method, $feed, $entry, $form) {
    if ($form['title'] == 'My Special Form') {
        return 'PUT';
    } else {
        return $request_method;
    }
}

Change request method based on feed name

This example changes the webhook HTTP request method to DELETE for webhooks with a specific feed name.

add_filter('gform_webhooks_request_method', 'change_method_based_on_feed_name', 10, 4);

function change_method_based_on_feed_name($request_method, $feed, $entry, $form) {
    if ($feed['meta']['name'] == 'Delete Webhook') {
        return 'DELETE';
    } else {
        return $request_method;
    }
}