Action
uncanny-automator
automator_triggers_registered
Fires after all automation triggers have been registered. Fires after all automation triggers are registered, providing a list of unique triggers.
add_action( 'automator_triggers_registered', $callback, 10, 1 );
Description
Fires after all automation triggers are registered. Developers can hook into this action to access the full list of registered triggers, `$unique_triggers`. This is useful for inspecting or programmatically interacting with the available triggers before automations begin processing.
Usage
add_action( 'automator_triggers_registered', 'your_function_name', 10, 1 );
Parameters
-
$unique_triggers(array) - List of unique triggers that were registered.
Examples
// Example of how to hook into the 'automator_triggers_registered' action.
// This example will log the names of all registered triggers to the debug log.
add_action( 'automator_triggers_registered', function( $unique_triggers ) {
// Ensure the debug log is enabled before proceeding to avoid errors.
if ( WP_DEBUG === true && WP_DEBUG_LOG === true ) {
// Get the current log file path.
$log_file = WP_CONTENT_DIR . '/debug.log';
// Format the trigger names for logging.
$trigger_names = array_column( $unique_triggers, 'name' );
$log_message = "Automator Triggers Registered: " . implode( ', ', $trigger_names ) . "n";
// Write the message to the debug log.
error_log( $log_message, 3, $log_file );
}
}, 10, 1 ); // Priority 10, accepts 1 argument.
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/actionify-triggers/class-trigger-engine.php:86
public function register_automation_hooks() {
$active_triggers = $this->query->get_active_triggers();
if ( empty( $active_triggers ) ) {
return;
}
$flattened_triggers = $this->flatten_trigger_array( $active_triggers );
$unique_triggers = $this->remove_duplicate_triggers( $flattened_triggers );
foreach ( $unique_triggers as $trigger ) {
$this->register_single_trigger( (array) $trigger );
}
/**
* Fires after all automation triggers have been registered.
*
* @param array $unique_triggers List of unique triggers that were registered.
*/
do_action( 'automator_triggers_registered', $unique_triggers );
}