The automatic_updater_disabled WordPress PHP filter allows you to control whether or not to disable background updates entirely.
Usage
add_filter('automatic_updater_disabled', 'your_custom_function'); function your_custom_function($disabled) { // your custom code here return $disabled; }
Parameters
$disabled
(bool): Determines if the updater should be disabled.
More information
See WordPress Developer Resources: automatic_updater_disabled
This filter offers more fine-grained control than the AUTOMATIC_UPDATER_DISABLED
constant. It also disables update notification emails, but this may change in future updates.
Examples
Disable automatic updates
To disable automatic updates:
add_filter('automatic_updater_disabled', 'disable_automatic_updates'); function disable_automatic_updates($disabled) { $disabled = true; return $disabled; }
Enable automatic updates
To enable automatic updates:
add_filter('automatic_updater_disabled', 'enable_automatic_updates'); function enable_automatic_updates($disabled) { $disabled = false; return $disabled; }
Disable automatic updates for specific user roles
To disable automatic updates for specific user roles:
add_filter('automatic_updater_disabled', 'disable_updates_for_user_role'); function disable_updates_for_user_role($disabled) { if (current_user_can('editor')) { $disabled = true; } return $disabled; }
Disable automatic updates on weekends
To disable automatic updates on weekends:
add_filter('automatic_updater_disabled', 'disable_updates_on_weekends'); function disable_updates_on_weekends($disabled) { $current_day = date('w'); if ($current_day == 0 || $current_day == 6) { $disabled = true; } return $disabled; }
Enable automatic updates only on specific time
To enable automatic updates only between 1 AM and 3 AM:
add_filter('automatic_updater_disabled', 'enable_updates_on_specific_time'); function enable_updates_on_specific_time($disabled) { $current_hour = date('G'); if ($current_hour >= 1 && $current_hour <= 3) { $disabled = false; } else { $disabled = true; } return $disabled; }