Filter
uncanny-automator-pro
automator_pro_auto_purge_logs_force_delete
Filters whether to force delete logs for Automator Pro, controlling the purge value and action.
add_filter( 'automator_pro_auto_purge_logs_force_delete', $callback, 10, 1 );
Description
Fires before logs are potentially deleted based on purge settings. Developers can use this filter to programmatically force deletion of logs, regardless of the configured purge settings, by returning `true`. If `false` is returned, the standard purge logic will be applied.
Usage
add_filter( 'automator_pro_auto_purge_logs_force_delete', 'your_function_name', 10, 1 );
Parameters
-
$purge_value(mixed) - This parameter is a boolean value that controls whether to force delete logs, overriding any other purging logic.
Return Value
The filtered value.
Examples
/**
* Example filter for 'automator_pro_auto_purge_logs_force_delete'.
*
* This filter can be used to override the default logic for forcing the deletion
* of automation logs, even if the purge value is not set or is less than 1.
* For demonstration purposes, this example will always force deletion,
* bypassing the default checks.
*
* @param mixed $default_force_delete The default value for forcing deletion (usually false).
* @param mixed $purge_value The number of days or units to purge logs.
* @return bool True to force deletion, false otherwise.
*/
add_filter( 'automator_pro_auto_purge_logs_force_delete', function( $default_force_delete, $purge_value ) {
// In a real-world scenario, you might add complex conditions here.
// For this example, we'll simply override the default and always return true,
// which will force the deletion process to proceed regardless of $purge_value.
// This is generally NOT recommended for production unless you have a very
// specific use case and fully understand the implications.
// Example of a more conditional logic (commented out for this specific example):
// if ( ! current_user_can( 'manage_options' ) ) {
// return $default_force_delete; // Only administrators can force delete.
// }
// if ( ! empty( $purge_value ) && intval( $purge_value ) >= 7 ) {
// return true; // Force delete if purge value is 7 days or more.
// }
// Forcing deletion in this example.
return true;
}, 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
uncanny-automator-pro/src/core/extensions/activity-log-settings.php:142
public function delete_old_logs() {
$purge_value = apply_filters(
'automator_pro_auto_purge_logs_days',
automator_get_option( 'uap_automator_purge_days', '' )
);
$unit = automator_get_option( 'uap_automator_purge_unit', 'days' );
if ( false === apply_filters( 'automator_pro_auto_purge_logs_force_delete', false, $purge_value ) ) {
if ( empty( $purge_value ) || intval( $purge_value ) < 1 ) {
return;
}
}
$this->delete_records( $purge_value, $unit );
}