Filter
uncanny-automator-pro
automator_pro_schedule_repeat_count
Filters the repeat count for scheduled automations, allowing customization before the schedule is applied.
add_filter( 'automator_pro_schedule_repeat_count', $callback, 10, 1 );
Description
Filters the maximum number of times a scheduled action can repeat. Developers can increase or decrease this value to control the upper limit of repeat intervals available to users. Defaults to 20.
Usage
add_filter( 'automator_pro_schedule_repeat_count', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of how to modify the default repeat count for schedules.
*
* By default, Uncanny Automator Pro allows schedules to repeat up to 20 times.
* This filter allows you to increase or decrease that limit.
*
* @param int $repeat_count The current maximum repeat count.
* @return int The modified maximum repeat count.
*/
function my_automator_pro_custom_schedule_repeat_count( $repeat_count ) {
// Let's say we want to allow schedules to repeat up to 50 times.
$custom_repeat_count = 50;
// Ensure we don't accidentally set it to be less than the initial values (1 or 2).
if ( $custom_repeat_count < 2 ) {
$custom_repeat_count = 2;
}
return $custom_repeat_count;
}
add_filter( 'automator_pro_schedule_repeat_count', 'my_automator_pro_custom_schedule_repeat_count', 10, 1 );
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/integrations/schedule/helpers/schedule-helpers.php:347
public function get_repeat_field( $recurring_trigger = false ) {
$v = '-1';
if ( $recurring_trigger ) {
$v = '300';
}
$options = array(
array(
'value' => $v,
'text' => esc_attr_x( 'Until cancelled', 'schedule', 'uncanny-automator-pro' ),
),
array(
'value' => '1',
'text' => esc_attr_x( '1 time', 'schedule', 'uncanny-automator-pro' ),
),
);
$count = apply_filters( 'automator_pro_schedule_repeat_count', 20 );
// Starting from 2 since the first two are manually added
for ( $i = 2; $i <= $count; $i ++ ) {
$options[] = array(
'value' => (string) $i,
'text' => sprintf( esc_attr_x( '%s times', 'schedule count', 'uncanny-automator-pro' ), $i ),
);
}
return array(
'option_code' => 'REPEAT_TIMES',
'label' => esc_attr_x( 'Repeat', 'schedule', 'uncanny-automator-pro' ),
'description' => esc_html__( 'The number of times the recipe will run.', 'uncanny-automator-pro' ),
'input_type' => 'select',
'options_show_id' => false,
'options' => $options,
'required' => true,
'supports_custom_value' => true,
'custom_value_description' => esc_html__( 'Enter a numeric value, i.e., 30, etc.', 'uncanny-automator-pro' ),
);
}