Filter
uncanny-automator
automator_allow_users_to_delete_in_progress_recipe_runs
Filters whether users can delete in-progress recipe runs.
add_filter( 'automator_allow_users_to_delete_in_progress_recipe_runs', $callback, 10, 1 );
Description
Filters whether users can delete in-progress recipe runs. By default, users can delete runs. Developers can return `false` to prevent deletion, useful for safeguarding ongoing automation processes.
Usage
add_filter( 'automator_allow_users_to_delete_in_progress_recipe_runs', 'your_function_name', 10, 1 );
Parameters
-
$recipe_id(mixed) - This parameter determines whether users are allowed to delete recipe runs that are currently in progress.
Return Value
The filtered value.
Examples
/**
* Example: Prevent users from deleting in-progress recipe runs if they are not administrators.
*
* This filter allows you to control which users can delete recipe runs that are currently in progress.
* By default, it's set to 'true', allowing deletion. This example restricts it to administrators.
*
* @param bool $allow_deletion Whether to allow deletion of in-progress recipe runs.
* @param int $recipe_id The ID of the recipe the run belongs to.
*
* @return bool The modified value of $allow_deletion.
*/
add_filter(
'automator_allow_users_to_delete_in_progress_recipe_runs',
function ( $allow_deletion, $recipe_id ) {
// Only allow administrators to delete in-progress recipe runs.
if ( ! current_user_can( 'manage_options' ) ) {
return false; // Prevent deletion for non-administrators.
}
return $allow_deletion; // Otherwise, keep the default behavior.
},
10,
2 // Accepts 2 arguments: $allow_deletion and $recipe_id
);
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/admin-logs/wp-list-table/class-logs-list-table.php:524
);
$actions = array(
'view' => '<uap-log-dialog-button log-id="' . $recipe_log_id . '" recipe-id="' . $recipe_id . '" run-number="' . $run_number_log . '"></uap-log-dialog-button>',
);
// Delete button
if ( true === apply_filters( 'automator_allow_users_to_delete_in_progress_recipe_runs', true, $recipe_id ) ) {
$delete_btn = '<uo-button
class="uap-logs-action-button uap-logs-action-button--delete"
size="small"
color="transparent"
href="%1$s"
uap-tooltip="' . esc_attr__( 'Delete row', 'uncanny-automator' ) . '"