Action uncanny-automator

automator_recipe_log_deleted

Fires after a recipe log entry is deleted, providing the recipe, log, and run numbers.

add_action( 'automator_recipe_log_deleted', $callback, 10, 3 );

Description

Fires after a specific recipe log entry has been deleted from the database. Developers can use this hook to perform custom cleanup tasks, such as removing associated cached data, updating custom meta, or logging the deletion event for auditing purposes. It provides the recipe ID, log ID, and run number for context.


Usage

add_action( 'automator_recipe_log_deleted', 'your_function_name', 10, 3 );

Parameters

$recipe_id (mixed)
The ID of the recipe associated with the deleted log entry.
$log_id (mixed)
The ID of the recipe for which a log entry was deleted.
$run_number (mixed)
The `$log_id` parameter contains the unique identifier of the specific log entry that is being deleted.

Examples

add_action( 'automator_recipe_log_deleted', function( $recipe_id, $log_id, $run_number ) {
    // This function is a placeholder to demonstrate how to hook into the 'automator_recipe_log_deleted' action.
    // In a real-world scenario, you might want to perform cleanup tasks or log this event for auditing purposes.

    // Example: Log the deletion event to the WordPress debug log.
    if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
        error_log( sprintf(
            'Uncanny Automator: Recipe log deleted. Recipe ID: %s, Log ID: %s, Run Number: %s',
            $recipe_id,
            $log_id,
            $run_number
        ) );
    }

    // Example: If you had other related data that needed to be cleaned up when a log is deleted,
    // you would add that logic here. For instance, if you stored custom metadata related to a log entry.
    // global $wpdb;
    // $wpdb->delete( $wpdb->prefix . 'automator_custom_meta', array( 'log_id' => $log_id ) );

}, 10, 3 );

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/admin/class-prune-logs.php:495
src/core/admin/class-activity-log.php:118
uncanny-automator-pro/src/core/extensions/activity-log-settings.php:227

public function purge_logs( $recipe_id, $log_id, $run_number ) {

		// Prune api logs.
		automator_purge_api_logs( $recipe_id, $log_id );
		// Prune recipe logs.
		automator_purge_recipe_logs( $recipe_id, $log_id );
		// Prune trigger logs.
		automator_purge_trigger_logs( $recipe_id, $log_id );
		// Prune action logs.
		automator_purge_action_logs( $recipe_id, $log_id );
		// Prune closure logs.
		automator_purge_closure_logs( $recipe_id, $log_id );

		do_action( 'automator_recipe_log_deleted', $recipe_id, $log_id, $run_number );
	}


Internal Usage

Found in uncanny-automator-pro/src/core/loops/loop-entry-point.php:70:

add_action( 'automator_recipe_log_deleted', array( $this, 'purge_recipe_run_loops_process' ), 10, 3 );
Scroll to Top