Filter
uncanny-automator
automator_recipe_remove_entry_on_completion
Filters whether an entry should be removed from the automator recipe after successful completion.
add_filter( 'automator_recipe_remove_entry_on_completion', $callback, 10, 2 );
Description
Filters whether to remove a completed recipe's log entry. Developers can use this to conditionally keep log entries for debugging or auditing purposes. Defaults to true, meaning entries are removed.
Usage
add_filter( 'automator_recipe_remove_entry_on_completion', 'your_function_name', 10, 2 );
Parameters
-
$setting_on(mixed) - This parameter indicates whether the setting to delete recipe records on completion is enabled or disabled.
-
$params(mixed) - This parameter indicates whether the setting to delete recipe records upon completion is enabled or disabled.
Return Value
The filtered value.
Examples
// Example: Conditionally prevent recipe entries from being removed on completion
// based on a specific recipe ID.
add_filter( 'automator_recipe_remove_entry_on_completion', function( $setting_on, $params ) {
// $params is expected to be an array containing recipe data,
// including 'recipe_id'.
if ( isset( $params['recipe_id'] ) && 123 === intval( $params['recipe_id'] ) ) {
// For recipe ID 123, always keep the entry, regardless of the setting.
return false;
}
// Otherwise, return the original setting value.
return $setting_on;
}, 10, 2 ); // Priority 10, accepts 2 arguments
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:710
public static function should_remove_log( $params ) {
$setting_on = automator_get_option( 'automator_delete_recipe_records_on_completion', false );
if ( empty( $setting_on ) || false === boolval( $setting_on ) ) {
$setting_on = false;
} else {
$setting_on = true;
}
return apply_filters( 'automator_recipe_remove_entry_on_completion', $setting_on, $params );
}