Action uncanny-automator

automator_recipe_option_updated_before_cache_is_cleared

Fires before cache is cleared when a recipe option is updated, providing access to the updated item and recipe ID.

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $callback, 10, 2 );

Description

Fires before the automator recipe option cache is cleared after an update. This hook allows developers to perform actions with the updated recipe item and its ID before cache invalidation, useful for logging or immediate post-update processing.


Usage

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', 'your_function_name', 10, 2 );

Parameters

$item (mixed)
This parameter holds the specific option that has just been updated within the recipe.
$recipe_id (mixed)
This parameter contains the updated value of the recipe option.

Examples

/**
 * Logs when a recipe option is updated before cache is cleared.
 *
 * This example demonstrates how to hook into the 'automator_recipe_option_updated_before_cache_is_cleared'
 * action to perform custom logging. It receives the updated item and the recipe ID.
 *
 * @param mixed $item The updated item data.
 * @param int $recipe_id The ID of the recipe being updated.
 */
add_action( 'automator_recipe_option_updated_before_cache_is_cleared', function( $item, $recipe_id ) {
	// Ensure Uncanny Automator is active and the logger function is available.
	if ( function_exists( 'Automator' ) && method_exists( Automator()->logger, 'add' ) ) {
		$recipe_title = get_the_title( $recipe_id );
		$log_message = sprintf(
			'Recipe "%s" (ID: %d) option updated. Item data: %s',
			esc_html( $recipe_title ),
			absint( $recipe_id ),
			maybe_serialize( $item ) // Serialize item for better log readability if it's complex.
		);
		Automator()->logger->add( 'recipe_updates', $log_message );
	}
}, 10, 2 );

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/automator-post-types/uo-recipe/class-recipe-post-rest-api.php:739

* and it happens to use Background processing
					 *
					 * @since 4.6
					 */
					$this->has_action_token( $item, $meta_value );
				}

				do_action( 'automator_recipe_option_updated_before_cache_is_cleared', $item, $recipe_id );

				Automator()->cache->clear_automator_recipe_part_cache( $recipe_id );

				$return['message']        = 'Option updated!';
				$return['success']        = true;
				$return['action']         = 'updated_option';
				$return['data']           = array( $item, $meta_key, $meta_value );


Internal Usage

Found in uncanny-automator-pro/src/integrations/loopable-rss/actions/loopable-rss-action.php:111:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );

Found in uncanny-automator-pro/src/integrations/loopable-rss/triggers/loopable-rss-trigger.php:104:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );

Found in uncanny-automator-pro/src/integrations/loopable-json/actions/loopable-json-action.php:111:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );

Found in uncanny-automator-pro/src/integrations/loopable-json/triggers/loopable-json-trigger.php:106:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );

Found in uncanny-automator-pro/src/integrations/loopable-csv/actions/loopable-csv-action.php:103:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );

Found in uncanny-automator-pro/src/integrations/loopable-csv/triggers/loopable-csv-trigger.php:106:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );

Found in uncanny-automator-pro/src/integrations/loopable-xml/actions/loopable-xml-action.php:110:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );

Found in uncanny-automator-pro/src/integrations/loopable-xml/triggers/loopable-xml-trigger.php:106:

add_action( 'automator_recipe_option_updated_before_cache_is_cleared', $closure, 10, 2 );
Scroll to Top