The gform_webhooks_request_url Gravity Forms PHP filter allows you to modify the webhook HTTP request URL.
Usage
add_filter('gform_webhooks_request_url', 'your_function_name', 10, 4);
Parameters
- $request_url (string): The HTTP request URL.
- $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_url
Examples
Modify the request URL
This example modifies the request URL to point to your custom domain.
add_filter('gform_webhooks_request_url', 'set_custom_request_url', 10, 4); function set_custom_request_url($request_url, $feed, $entry, $form) { $request_url = 'https://www.your.custom.domain'; return $request_url; }
Add a query parameter to the request URL
This example adds a query parameter called ‘api_key’ to the request URL.
add_filter('gform_webhooks_request_url', 'add_api_key', 10, 4); function add_api_key($request_url, $feed, $entry, $form) { $api_key = 'your_api_key'; $request_url = $request_url . '?api_key=' . $api_key; return $request_url; }
Change the request URL based on form ID
This example changes the request URL based on the form ID.
add_filter('gform_webhooks_request_url', 'set_url_based_on_form_id', 10, 4); function set_url_based_on_form_id($request_url, $feed, $entry, $form) { if ($form['id'] == 1) { $request_url = 'https://www.example1.com'; } elseif ($form['id'] == 2) { $request_url = 'https://www.example2.com'; } return $request_url; }
Modify the request URL using entry data
This example modifies the request URL by adding an entry field value as a query parameter.
add_filter('gform_webhooks_request_url', 'add_entry_data_to_url', 10, 4); function add_entry_data_to_url($request_url, $feed, $entry, $form) { $field_value = rgar($entry, '1'); // Replace '1' with the field ID $request_url = $request_url . '?field_value=' . $field_value; return $request_url; }
Modify the request URL using a custom function
This example modifies the request URL by calling a custom function that returns a new URL.
add_filter('gform_webhooks_request_url', 'change_url_with_custom_function', 10, 4); function change_url_with_custom_function($request_url, $feed, $entry, $form) { $request_url = get_custom_request_url(); return $request_url; } function get_custom_request_url() { // Your custom code here return 'https://www.custom.url'; }