Action
uncanny-automator
automator_complete_trigger_detail
Fires when details for a trigger are being retrieved, passing trigger and argument data.
add_action( 'automator_complete_trigger_detail', $callback, 10, 2 );
Description
Fires after the trigger sentence details have been retrieved and formatted. Developers can use this hook to modify or log the trigger data, or perform actions based on the trigger's specifics before it's finalized. Access the trigger data and arguments for customization.
Usage
add_action( 'automator_complete_trigger_detail', 'your_function_name', 10, 2 );
Parameters
-
$trigger_data(mixed) - This parameter contains the human-readable sentence describing the completed trigger.
-
$args(mixed) - This parameter contains the human-readable sentence representing the completed trigger details.
Examples
add_action( 'automator_complete_trigger_detail', function( $trigger_data, $args ) {
// This example demonstrates how to log trigger details for debugging purposes.
// In a real-world scenario, you might use this hook to perform custom actions
// based on the trigger data, such as sending notifications or updating user meta.
// Check if we have trigger data to log.
if ( ! empty( $trigger_data ) && is_array( $trigger_data ) ) {
// Log the trigger data and any associated arguments to the WordPress debug log.
// You can access the debug log via the WP_DEBUG_LOG constant in wp-config.php.
error_log( 'Automator - Trigger Details: ' . print_r( $trigger_data, true ) );
if ( ! empty( $args ) ) {
error_log( 'Automator - Trigger Arguments: ' . print_r( $args, true ) );
}
}
}, 10, 2 ); // Priority 10, accepts 2 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/process/class-automator-recipe-process-user.php:851
*
* @version 2.5.1
* @author Saad
*
*/
$trigger_data = Automator()->get->trigger_sentence( $trigger_id, 'trigger_detail' );
do_action( 'automator_complete_trigger_detail', $trigger_data, $args );
$sentence_human_readable = $this->get_trigger_sentence( $trigger_id );
// Store trigger sentence details for the completion
// @Todo: Remove this process if not in used.
if ( ! empty( $sentence_human_readable ) ) {