Filter
Dynamic
uncanny-automator-pro
automator_pro_webhook_response_headers_{$recipe['ID']}
> **Note:** This is a dynamic hook. The actual hook name is constructed at runtime. Filters webhook response headers for a specific recipe to allow modification before sending.
add_filter( 'automator_pro_webhook_response_headers_{$recipe['ID']}', $callback, 10, 4 );
Description
Fires after webhook response headers are determined but before they are sent. Developers can filter and modify these headers dynamically based on the recipe ID, recipe details, and incoming webhook data. This allows for customized response headers for specific automations.
Usage
add_filter( 'automator_pro_webhook_response_headers_{$recipe['ID']}', 'your_function_name', 10, 4 );
Parameters
-
$response_headers(mixed) - The `$response_headers` parameter contains an array of the HTTP headers that will be sent back to the webhook sender.
-
$_hooks(mixed) - This parameter contains an array of HTTP response headers that will be sent back to the webhook caller.
-
$recipe(mixed) - This parameter contains information about the hooks that are currently being processed for the recipe.
-
$data(mixed) - This parameter contains the current recipe object being processed by the webhook.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to filter webhook response headers for a specific Uncanny Automator Pro recipe.
* This example adds a custom header 'X-Automator-Recipe-Status' indicating if the recipe was successful.
*/
add_filter( 'automator_pro_webhook_response_headers_123', 'my_custom_automator_webhook_headers', 10, 4 );
/**
* Filters the webhook response headers for a specific Uncanny Automator Pro recipe.
*
* @param array $_response_headers The current response headers.
* @param array $_hooks The webhook hooks data.
* @param array $recipe The recipe data.
* @param array $data The data passed to the webhook.
* @return array The modified response headers.
*/
function my_custom_automator_webhook_headers( $_response_headers, $_hooks, $recipe, $data ) {
// Assuming $data contains information about the success or failure of the recipe execution.
// You would need to inspect $data to determine the actual status.
// For this example, let's simulate a status based on whether the 'status' key exists and is 'success'.
$recipe_status = isset( $data['status'] ) && $data['status'] === 'success' ? 'success' : 'failed';
// Add a custom header to the response
$_response_headers['X-Automator-Recipe-Status'] = $recipe_status;
return $_response_headers;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/core/webhook/webhook-rest-handler.php:494
$response_data = apply_filters(
"automator_pro_webhook_response_{$recipe['ID']}",
$response_data,
$_hooks,
$recipe,
$data
);
$response_headers = apply_filters(
"automator_pro_webhook_response_headers_{$recipe['ID']}",
$response_headers,
$_hooks,
$recipe,
$data
);