Action
uncanny-automator
automator_actions_completed_run_flow
Fires after a WordPress Automator recipe's actions have finished running, providing context about the completed flow.
add_action( 'automator_actions_completed_run_flow', $callback, 10, 5 );
Description
Fires after all actions within a Uncanny Automator recipe have been processed and completed. Developers can use this hook to execute custom logic, log final recipe outcomes, or trigger subsequent processes based on the recipe's completion, including different flow types.
Usage
add_action( 'automator_actions_completed_run_flow', 'your_function_name', 10, 5 );
Parameters
-
$flow_type(mixed) - This parameter indicates the type of flow being executed, such as 'linear'.
-
$recipe_id(mixed) - This parameter specifies the type of flow that has just completed, such as 'linear'.
-
$user_id(mixed) - This parameter holds the unique identifier of the recipe being processed.
-
$recipe_log_id(mixed) - The `$user_id` parameter contains the ID of the user for whom the recipe is being processed.
-
$args(mixed) - The `$args` parameter contains an array of any additional arguments passed during the recipe execution.
Examples
/**
* Example function to demonstrate the 'automator_actions_completed_run_flow' hook.
* This function logs details about the completed flow and potentially performs
* additional actions based on the flow type.
*
* @param mixed $flow_type The type of flow that was completed (e.g., 'linear', 'branching').
* @param int $recipe_id The ID of the recipe that was triggered.
* @param int $user_id The ID of the user associated with the recipe execution.
* @param int $recipe_log_id The ID of the log entry for this recipe execution.
* @param array $args Additional arguments passed to the hook.
*/
function my_automator_handle_flow_completion( $flow_type, $recipe_id, $user_id, $recipe_log_id, $args ) {
// Log that a flow has completed for debugging or tracking.
error_log( sprintf(
'Automator: Flow of type "%s" completed for recipe ID %d, user ID %d, log ID %d.',
$flow_type,
$recipe_id,
$user_id,
$recipe_log_id
) );
// Example: If the flow was of a specific custom type, perform additional actions.
if ( 'custom_approval_flow' === $flow_type ) {
// Imagine you have a function to send a notification about the approval.
my_send_approval_notification( $recipe_id, $user_id, $recipe_log_id, $args );
}
// Example: Add a specific tag to the user if a certain condition is met.
if ( isset( $args['completed_action_slug'] ) && 'send-thank_you_email' === $args['completed_action_slug'] ) {
// Ensure the user exists before trying to tag them.
if ( $user_id && get_user_by( 'id', $user_id ) ) {
wp_add_user_tag( $user_id, 'automator-satisfied' );
}
}
// If this were a filter hook, you would return a value.
// For action hooks, no return value is strictly necessary unless you intend
// to pass data to subsequent callbacks in a specific way (which is less common for actions).
}
// Hook into the 'automator_actions_completed_run_flow' action.
// The priority is 10, and we accept 5 arguments.
add_action( 'automator_actions_completed_run_flow', 'my_automator_handle_flow_completion', 10, 5 );
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-complete.php:141
if ( 'linear' === $flow_type ) {
// If it does, run all actions that are 'linear'.
$this->complete_actions( $recipe_id, $user_id, $recipe_log_id, $args );
}
// Support custom flow types.
do_action( 'automator_actions_completed_run_flow', $flow_type, $recipe_id, $user_id, $recipe_log_id, $args );
}
$this->add_backtrace_property( $args );
return true;
}
Internal Usage
Found in uncanny-automator-pro/src/core/loops/loop-entry-point.php:58:
add_action( 'automator_actions_completed_run_flow', array( $this, 'process_as_flow' ), 10, 5 );