Action
uncanny-automator-pro
automator_pro_async_action_after_run_execution
Fires after an Automator Pro asynchronous action's execution has completed.
add_action( 'automator_pro_async_action_after_run_execution', $callback, 10, 1 );
Description
Fires after an asynchronous action has successfully completed its execution. Developers can use this hook to perform additional tasks or modify data related to the completed asynchronous action. It's ideal for logging, sending notifications, or triggering follow-up processes.
Usage
add_action( 'automator_pro_async_action_after_run_execution', 'your_function_name', 10, 1 );
Parameters
-
$action(mixed) - This parameter contains the data and ID of the action that is about to be executed asynchronously.
Examples
// Log the completion of an asynchronous action for debugging purposes.
add_action( 'automator_pro_async_action_after_run_execution', function( $action_data ) {
// Ensure we have valid action data before proceeding.
if ( ! is_array( $action_data ) || empty( $action_data ) ) {
return;
}
// Extract relevant information from the action data.
$action_id = $action_data['ID'];
$recipe_id = $action_data['RECIPE_ID'];
$action_type = $action_data['POST_TYPE'];
// Log to the WordPress debug log.
error_log( sprintf(
'Uncanny Automator Pro: Async action "%s" (ID: %d) for recipe "%d" has finished execution.',
$action_type,
$action_id,
$recipe_id
) );
}, 10, 1 );
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
uncanny-automator-pro/src/core/classes/async-actions.php:657
private function run_execution( $action ) {
if ( ! is_array( $action ) || empty( $action['action_data'] ) || empty( $action['recipe_id'] ) ) {
automator_log( 'Async action skipped — action data is missing or invalid.' );
return;
}
$action = apply_filters( 'automator_pro_before_async_action_executed', $action );
if ( isset( $action['process_further'] ) && false === $action['process_further'] ) {
automator_log( 'Action was skipped by automator_pro_before_async_action_executed filter.' );
return;
}
$action_id = $action['action_data']['ID'];
$recipe_id = $action['recipe_id'];
$action_post = get_post( $action_id );
$recipe_post = get_post( $recipe_id );
// If action or recipe no longer exists
if ( empty( $action_post ) || empty( $recipe_post ) || ! $action_post instanceof WP_Post || ! $recipe_post instanceof WP_Post ) {
$this->recipe_or_action_no_longer_exists( $action );
return;
}
// If action or recipe is set to draft
if ( 'publish' !== $action_post->post_status || 'publish' !== $recipe_post->post_status ) {
$this->recipe_or_action_is_not_live( $action );
return;
}
$action_code = $action['action_data']['meta']['code'];
$action_execution_function = Automator()->get->action_execution_function_from_action_code( $action_code );
$action['action_data']['async']['status'] = 'completed';
$action['action_data']['async']['completed_at'] = current_time( 'timestamp' ); //phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
if ( isset( $action['process_further'] ) ) {
unset( $action['process_further'] );
}
if ( empty( $action_execution_function ) ) {
$this->missing_execution_function( $action );
return;
}
try {
call_user_func_array( $action_execution_function, $action );
do_action( 'automator_pro_async_action_after_run_execution', $action );
} catch ( Error $e ) {
$this->complete_with_error( $action, $e->getMessage() );
} catch ( Exception $e ) {
$this->complete_with_error( $action, $e->getMessage() );
}
}
Internal Usage
Found in src/core/lib/recipe-parts/actions/trait-action-tokens.php:133:
add_action( 'automator_pro_async_action_after_run_execution', array( $this, 'handle_automator_pro_async_action' ), 10, 1 );
Found in uncanny-automator-pro/src/core/classes/action-tokens-helpers.php:25:
add_action( 'automator_pro_async_action_after_run_execution', array( $this, 'update_action_token_record' ), 10, 1 );