Filter
uncanny-automator-pro
automator_pro_webhook_params_pre_handle_params
Filters webhook parameters before they are handled, allowing modification of params, trigger, and data.
add_filter( 'automator_pro_webhook_params_pre_handle_params', $callback, 10, 3 );
Description
Fires before webhook parameters are processed, allowing modification of `$params`, the `$trigger` details, and the raw `$data`. Developers can use this to sanitize, transform, or conditionally alter incoming webhook data before it's used to initiate automations. Ensure the returned `$params` remain compatible with subsequent processing.
Usage
add_filter( 'automator_pro_webhook_params_pre_handle_params', 'your_function_name', 10, 3 );
Parameters
-
$params(mixed) - This parameter holds an array or object containing the parsed parameters extracted from the webhook request body, intended to be used by automations.
-
$trigger(mixed) - This parameter contains the data array that will be passed to the automation trigger.
-
$data(mixed) - This parameter contains information about the specific trigger that is being processed by the webhook.
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to use the 'automator_pro_webhook_params_pre_handle_params' filter.
* This filter allows you to modify the webhook parameters before they are processed by Uncanny Automator.
* In this example, we'll add a custom parameter if a specific trigger meta key is present.
*
* @param mixed $params The current webhook parameters.
* @param mixed $trigger_meta The meta data associated with the trigger.
* @param mixed $data The raw data received from the webhook.
* @return mixed The modified webhook parameters.
*/
add_filter( 'automator_pro_webhook_params_pre_handle_params', function( $params, $trigger_meta, $data ) {
// Check if the trigger meta contains a specific key, for example, to identify a particular integration.
if ( isset( $trigger_meta['integration'] ) && 'my_custom_integration' === $trigger_meta['integration'] ) {
// Add a custom parameter to the $params array.
// This could be used to pass additional context to Uncanny Automator.
$params['my_custom_context'] = 'processed_by_my_filter';
// You could also modify existing parameters if needed.
if ( isset( $params['email'] ) ) {
$params['email'] = strtolower( $params['email'] ); // Ensure email is lowercase.
}
}
// Always return the parameters, whether modified or not.
return $params;
}, 10, 3 );
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:403
return new WP_REST_Response( $response_data, $response_status_code, $response_headers );
}
$data_type = isset( $trigger['meta']['DATA_FORMAT'] ) ? $trigger['meta']['DATA_FORMAT'] : 'json';
if ( ! empty( $body ) && empty( $params ) ) {
$params = self::handle_non_json_type_format( $body, $data_type );
}
$params = apply_filters( 'automator_pro_webhook_params_pre_handle_params', $params, $trigger['meta'], $data );
$parsed_fields = self::handle_params( $params );
foreach ( $_fields as $_field ) {
if ( isset( $parsed_fields[ $_field->KEY ] ) ) { //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$value = $parsed_fields[ $_field->KEY ]; //phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
} else {
$value = apply_filters( 'automator_pro_webhook_field_key_not_found', __( 'Key not found in data', 'uncanny-automator-pro' ), $_field, $parsed_fields, $_fields, $data );
}