Filter
uncanny-automator-pro
automator_queue_next_delay
Filters the delay in seconds before the next queued item is processed.
add_filter( 'automator_queue_next_delay', $callback, 10, 1 );
Description
Fires after a queue item is processed but before the next one is fetched, allowing developers to introduce a custom delay. This hook controls the pause between processing subsequent queue items, helping to manage server load or external API rate limits. The default delay is 0 seconds.
Usage
add_filter( 'automator_queue_next_delay', 'your_function_name', 10, 1 );
Parameters
-
$process_id(mixed) - This parameter contains the ID of the process currently being processed, which can be used to adjust the delay based on the specific process.
Return Value
The filtered value.
Examples
<?php
/**
* Example: Increase the delay between queue removals for specific processes.
*
* This filter allows you to introduce a delay between processing individual
* items in the Uncanny Automator queue. This can be useful for preventing
* server overload during periods of high automation activity.
*
* @param int $delay The current delay in seconds. Defaults to 0.
* @param string $process_id The ID of the current process being handled.
*
* @return int The new delay in seconds.
*/
function my_automator_custom_queue_delay( $delay, $process_id ) {
// If the process ID matches a specific automation we want to throttle more,
// set a longer delay. For example, if the process_id is 'user_signup_automation'.
if ( 'user_signup_automation' === $process_id ) {
return 5; // Set a 5-second delay for this specific process.
}
// For all other processes, use the default delay (which is 0 if not set elsewhere).
return $delay;
}
add_filter( 'automator_queue_next_delay', 'my_automator_custom_queue_delay', 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/loops/loop-queue.php:79
public function remove( $process_id ) {
// Optional throttle between queue removals. Default 0 (no delay).
$delay = (int) apply_filters( 'automator_queue_next_delay', 0, $process_id );
if ( $delay > 0 ) {
sleep( $delay );
}
$queue_item = $this->get( $process_id );
if ( false === $queue_item ) {
return false;
}
$deleted = $this->db->delete(
$this->table,
array(
'ID' => $queue_item['ID'],
),
array(
'%d',
)
);
return $deleted;
}