The gform_webhooks_request_headers filter allows you to modify the webhook HTTP request headers.
Usage
To apply this filter to all forms:
add_filter('gform_webhooks_request_headers', 'your_function_name', 10, 4);
To target a specific form, append the form id to the hook name:
add_filter('gform_webhooks_request_headers_14', 'your_function_name', 10, 4);
Parameters
$request_headers
(array): HTTP request headers.$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_request_headers
This filter is located in GF_Webhooks::process_feed()
in gravityformswebhooks/class-gf-webhooks.php
.
Examples
Set the From header
Modify the ‘From’ header for the webhook request:
add_filter('gform_webhooks_request_headers', 'set_headers', 10, 4); function set_headers($request_headers, $feed, $entry, $form) { $request_headers['From'] = '[email protected]'; return $request_headers; }
Set the authorization header with a bearer token
Generate and add a bearer token to the authorization header using a third-party service:
add_filter('gform_webhooks_request_headers', function ($request_headers) { $token = 'your_bearer_token'; $request_headers['Authorization'] = 'Bearer ' . $token; return $request_headers; });
Set the authorization header using JWT Library and Zoom API
Generate and add a bearer token to the authorization header using the JWT PHP Library and Zoom API:
add_filter('gform_webhooks_request_headers', function ($request_headers) { // Requires JWT PHP Library: https://github.com/firebase/php-jwt if (class_exists('JWT')) { $key = '<zoom_api_key>'; $secret = '<zoom_api_secret>'; $token = array( "iss" => $key, "exp" => time() + 60 ); $request_headers['Authorization'] = 'Bearer ' . JWT::encode($token, $secret); } return $request_headers; });
Set the Basic Authorization header
Add the Basic Authorization header to authenticate a request:
add_filter('gform_webhooks_request_headers', function ($request_headers) { $username = 'your_username'; $password = 'your_password'; $request_headers['Authorization'] = 'Basic ' . base64_encode($username . ':' . $password); return $request_headers; }, 10, 2);
Note: Replace your_username
and your_password
with your actual credentials.