Action Since 7.0 uncanny-automator

automator_recipe_item_update_complete

Fires when a recipe item update is complete. Fires when a recipe item's update is complete, providing details about the item and its recipe.

add_action( 'automator_recipe_item_update_complete', $callback, 10, 6 );

Description

Fires after an Automator recipe item has been successfully updated via the API. Developers can use this hook to perform custom actions based on the updated item's ID, code, type, associated recipe, and service return data. This provides a powerful extension point for modifying or reacting to recipe item changes.


Usage

add_action( 'automator_recipe_item_update_complete', 'your_function_name', 10, 6 );

Parameters

$item_id (int|string)
The item ID.
$item_code (string)
The item code.
$recipe_id (int)
The recipe ID.
$item_type (string)
The item type (trigger, action, closure, filter_condition).
$item_data (array)
Service return data.
$recipe (object)
Recipe aggregate object.

Examples

<?php
/**
 * Example callback function for the 'automator_recipe_item_update_complete' action hook.
 * This function logs the details of a recipe item that has been updated.
 *
 * @param int|string $item_id   The item ID.
 * @param string     $item_code The item code.
 * @param int        $recipe_id The recipe ID.
 * @param string     $item_type The item type (trigger, action, closure, filter_condition).
 * @param array      $item_data Service return data.
 * @param object     $recipe    Recipe aggregate object.
 */
function my_automator_recipe_item_updated_log( $item_id, $item_code, $recipe_id, $item_type, $item_data, $recipe ) {
    // In a real-world scenario, you might want to:
    // - Send a notification to an admin.
    // - Update a custom database table with this information.
    // - Trigger another process based on the updated item.

    // For this example, we'll simply log the event to the WordPress debug log.
    if ( WP_DEBUG === true ) {
        error_log(
            sprintf(
                '[My Automator Logger] Recipe item updated: ID=%s, Code=%s, Recipe ID=%d, Type=%s. Item Data: %s',
                $item_id,
                $item_code,
                $recipe_id,
                $item_type,
                print_r( $item_data, true ) // Use print_r for array output in logs
            )
        );

        // You could also access properties of the $recipe object if needed.
        // For example, if the recipe object has a get_title() method:
        // error_log( 'Recipe Title: ' . $recipe->get_title() );
    }
}

// Add the callback function to the 'automator_recipe_item_update_complete' action hook.
// The '6' indicates the number of arguments the callback function accepts.
add_action( 'automator_recipe_item_update_complete', 'my_automator_recipe_item_updated_log', 10, 6 );
?>

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/api/transports/restful/recipe/items/traits/hooks/trait-hook-update-operations.php:66

protected function dispatch_update_complete_hooks( array $item_data, object $recipe ): void {
		$type = $this->get_item_type();

		/**
		 * Fires when a recipe item update is complete.
		 *
		 * @since 7.0
		 *
		 * @param int|string $item_id   The item ID.
		 * @param string     $item_code The item code.
		 * @param int        $recipe_id The recipe ID.
		 * @param string     $item_type The item type (trigger, action, closure, filter_condition).
		 * @param array      $item_data Service return data.
		 * @param object     $recipe    Recipe aggregate object.
		 */
		do_action(
			'automator_recipe_item_update_complete',
			$this->get_item_id(),
			$this->get_item_code(),
			$this->get_recipe_id(),
			$type,
			$item_data,
			$recipe
		);

		/**
		 * Fires when a specific recipe item type update is complete.
		 *
		 * @since 7.0
		 *
		 * @param int|string $item_id   The item ID.
		 * @param string     $item_code The item code.
		 * @param int        $recipe_id The recipe ID.
		 * @param array      $item_data Service return data.
		 * @param object     $recipe    Recipe aggregate object.
		 */
		do_action(
			"automator_recipe_{$type}_update_complete",
			$this->get_item_id(),
			$this->get_item_code(),
			$this->get_recipe_id(),
			$item_data,
			$recipe
		);
	}


Scroll to Top