Action uncanny-automator

automator_recipe_completed

Fires when an Automator recipe successfully completes, providing its ID, the user, and log details.

add_action( 'automator_recipe_completed', $callback, 10, 4 );

Description

Fires after a user successfully completes a recipe. Developers can use this hook to trigger custom actions, update user meta, send notifications, or integrate with other services based on recipe completion. It provides the completed recipe ID, user ID, recipe log ID, and any additional arguments passed.


Usage

add_action( 'automator_recipe_completed', 'your_function_name', 10, 4 );

Parameters

$recipe_id (mixed)
The ID of the recipe that has been completed.
$user_id (mixed)
This parameter contains the unique identifier for the completed recipe.
$recipe_log_id (mixed)
The ID of the user for whom the recipe was completed.
$args (mixed)
This parameter contains the unique identifier for the log entry generated for this specific recipe completion.

Examples

/**
 * When a recipe is completed, log the completion time and the user who completed it.
 *
 * @param int $recipe_id The ID of the completed recipe.
 * @param int $user_id The ID of the user who completed the recipe.
 * @param int $recipe_log_id The ID of the recipe log entry.
 * @param array $args Additional arguments passed to the hook.
 */
function my_automator_log_recipe_completion( $recipe_id, $user_id, $recipe_log_id, $args ) {
    global $wpdb;

    $table_name = $wpdb->prefix . 'my_automator_completions';

    // Log the completion details
    $wpdb->insert(
        $table_name,
        array(
            'recipe_id'     => $recipe_id,
            'user_id'       => $user_id,
            'recipe_log_id' => $recipe_log_id,
            'completed_at'  => current_time( 'mysql' ),
            'additional_data' => maybe_serialize( $args ), // Serialize if there are extra args to store
        )
    );
}
add_action( 'automator_recipe_completed', 'my_automator_log_recipe_completion', 10, 4 );

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:988

$recipe_log_id,
				$args,
			),
			'3.0',
			'automator_recipe_completed'
		);

		do_action( 'automator_recipe_completed', $recipe_id, $user_id, $recipe_log_id, $args );

		return true;
	}

	/**
	 * Find the first actionable error from all actions in a recipe.
	 *


Internal Usage

Found in src/core/services/resolver/fields-shared-callable.php:40:

add_action( 'automator_recipe_completed', array( self::$instance, 'clear' ) );

Found in src/core/classes/class-usage-reports.php:77:

add_action( 'automator_recipe_completed', array( $this, 'count_recipe_completion' ) );

Found in src/core/services/singleton/parsed-token-records-singleton.php:99:

add_action( 'automator_recipe_completed', array( $this, 'clear' ) );

Found in src/core/services/logger/singleton/async-action-logger-singleton.php:73:

add_action( 'automator_recipe_completed', array( $this, 'clear' ) );

Found in src/integrations/uncanny-automator/triggers/uoa-user-completes-recipe-numtimes.php:50:

$this->add_action( 'automator_recipe_completed' );
Scroll to Top