Filter
uncanny-automator
automator_skip_trigger_registration
Filters whether a specific trigger should be registered by the Automator plugin.
add_filter( 'automator_skip_trigger_registration', $callback, 10, 4 );
Description
Allows developers to conditionally skip the registration of specific triggers. By returning `true`, you can prevent a trigger from being loaded or processed by the Automator. This is useful for excluding certain trigger types or for integration-specific logic.
Usage
add_filter( 'automator_skip_trigger_registration', 'your_function_name', 10, 4 );
Parameters
-
$skip_trigger_registration(mixed) - This parameter is a boolean value that determines whether the current trigger should be skipped during registration.
-
$trigger(mixed) - This boolean value determines whether to skip the registration of the current trigger, allowing for conditional exclusion.
-
$integration_code(mixed) - This parameter represents the specific trigger object whose registration might be skipped.
-
$integration(mixed) - This parameter contains the unique code identifier for the integration that the trigger belongs to.
Return Value
The filtered value.
Examples
/**
* Conditionally skip registering a specific trigger based on integration and trigger type.
*
* For example, we might want to skip registering a 'New User Registered' trigger
* for a specific integration that handles user provisioning internally and doesn't
* need to trigger based on WordPress's native user registration.
*
* @param mixed $skip_trigger_registration The current value of the skip registration flag (initially false).
* @param mixed $trigger The trigger object or data being considered for registration.
* @param mixed $integration_code The unique code for the integration.
* @param mixed $integration The integration object or data.
*
* @return bool True to skip registration, false otherwise.
*/
add_filter(
'automator_skip_trigger_registration',
function( $skip_trigger_registration, $trigger, $integration_code, $integration ) {
// Define the integration code we want to target.
$target_integration_code = 'my_custom_crm';
// Define the type of trigger we want to skip for this integration.
$trigger_type_to_skip = 'user'; // For example, skip user-related triggers.
// Check if the current integration matches our target and if the trigger is of the type we want to skip.
if ( $integration_code === $target_integration_code && isset( $trigger->type ) && $trigger->type === $trigger_type_to_skip ) {
// If it matches, return true to skip registration for this trigger.
return true;
}
// Otherwise, return the original value, allowing the trigger to be registered.
return $skip_trigger_registration;
},
10, // Priority
4 // Accepted args
);
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:127
$trigger,
$integration_code,
$integration,
),
'3.0',
'automator_skip_trigger_registration'
);
$skip_trigger_registration = apply_filters( 'automator_skip_trigger_registration', $skip_trigger_registration, $trigger, $integration_code, $integration );
if ( true === $skip_trigger_registration ) {
return null;
}
/**
* Use this hook the override specific triggers type, i.e., utility or user
*/