Filter
uncanny-automator
automator_trigger_type
Filters the trigger type for an automation, allowing modification before it's used.
add_filter( 'automator_trigger_type', $callback, 10, 4 );
Description
Fires after a trigger type is determined but before it's registered. Developers can use this filter to dynamically alter the trigger's type based on the trigger object, its integration code, or the integration object itself. This allows for custom trigger type logic.
Usage
add_filter( 'automator_trigger_type', 'your_function_name', 10, 4 );
Parameters
-
$trigger_type(mixed) - This parameter contains the current trigger type being processed, which can be modified by filters.
-
$trigger(mixed) - This parameter holds the current trigger type, which can be modified by filters.
-
$integration_code(mixed) - This parameter contains the trigger object itself, which is being processed.
-
$integration(mixed) - This parameter contains the unique code or identifier for the integration the trigger belongs to.
Return Value
The filtered value.
Examples
/**
* Example function to modify the trigger type for a specific integration.
*
* This function will append a suffix to the trigger type if the integration
* code is 'my_custom_integration' and the trigger is for a 'new_order' event.
*
* @param string $trigger_type The current trigger type.
* @param array $trigger The trigger data array.
* @param string $integration_code The code of the integration.
* @param array $integration The integration data array.
*
* @return string The modified trigger type.
*/
add_filter(
'automator_trigger_type',
function ( $trigger_type, $trigger, $integration_code, $integration ) {
// Check if it's our custom integration and a specific trigger
if ( 'my_custom_integration' === $integration_code && isset( $trigger['event'] ) && 'new_order' === $trigger['event'] ) {
// Append a custom suffix to the trigger type
return $trigger_type . '_processed';
}
// Return the original trigger type if no modification is needed
return $trigger_type;
},
10, // Priority
4 // Number of accepted arguments
);
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
src/core/lib/utilities/class-automator-registration.php:148
$trigger,
$integration_code,
$integration,
),
'3.0',
'automator_trigger_type'
);
$trigger_type = apply_filters( 'automator_trigger_type', $trigger_type, $trigger, $integration_code, $integration );
$trigger['type'] = $trigger_type;
}
/**
* Use this hook to modify the trigger before it it error checked and registered
*/
$trigger = apply_filters_deprecated(