Action uncanny-automator-pro

automator_pro_before_loop_is_queued

Fires before the Automator Pro loop is queued, allowing customization before the process begins.

add_action( 'automator_pro_before_loop_is_queued', $callback, 10, 1 );

Description

Fires before a recipe loop is queued for execution, allowing for pre-loop modifications or checks. Developers can use this hook to access and potentially alter loop parameters like user ID, triggers, and recipe ID before the loop processing begins. This hook is essential for custom logic that needs to influence the loop's behavior early in its lifecycle.


Usage

add_action( 'automator_pro_before_loop_is_queued', 'your_function_name', 10, 1 );

Parameters

$this (mixed)
This parameter provides an array containing the user ID for the loop.

Examples

<?php
/**
 * Example of how to hook into the 'automator_pro_before_loop_is_queued' action.
 * This example demonstrates logging the user ID and recipe ID before a loop is queued.
 */
function my_automator_pro_log_loop_data( $loop_data ) {
	// Ensure we have the necessary data before proceeding.
	if ( ! isset( $loop_data['user_id'] ) || ! isset( $loop_data['recipe_id'] ) ) {
		error_log( 'Uncanny Automator Pro: Missing user_id or recipe_id in automator_pro_before_loop_is_queued hook.' );
		return;
	}

	$user_id   = $loop_data['user_id'];
	$recipe_id = $loop_data['recipe_id'];

	// Log the information for debugging or monitoring purposes.
	error_log( sprintf(
		'Uncanny Automator Pro: Loop is about to be queued for User ID: %1$s, Recipe ID: %2$s.',
		$user_id,
		$recipe_id
	) );

	// You could potentially perform other actions here, like updating a custom meta field
	// for the user or recipe based on the upcoming loop.
	// For example:
	// update_user_meta( $user_id, 'automator_loop_about_to_queue', $recipe_id );
}
add_action( 'automator_pro_before_loop_is_queued', 'my_automator_pro_log_loop_data', 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/loops/loop/execute.php:195

);
			}

			// Handles unexpected errors on initialization. Loop initialization is not yet run in the background and can fail due to memory issues.
			$this->handle_unexpected_bad_errors();

			// @since 5.10
			do_action(
				'automator_pro_before_loop_is_queued',
				array(
					'user_id'             => $this->get_user_id(),
					'triggers'            => $triggers,
					'recipe_id'           => $this->get_recipe_id(),
					'process_args'        => $this->get_process_args(),
					'recipe_log_id'       => $this->get_recipe_log_id(),

Internal Usage

Found in src/core/services/loopable/trigger-loopable-token.php:155:

add_action( 'automator_pro_before_loop_is_queued', $closure, 10, 1 );

Found in src/core/services/loopable/universal-loopable-token.php:73:

add_action( 'automator_pro_before_loop_is_queued', array( $this, 'on_before_loop_is_queued' ), 10, 1 );
Scroll to Top