We've turned on WordPress Auto-Updates (yey!), but, just in case this does break anything, we'd like to only run Auto-Updates during daylight hours (e.g. 09:00 - 17:30).

We have the "on init" WP-Cron disabled, and are calling it from the servers crontab every 10 minutes.

How can adapt the AutoUpdate, so all updates are run during these times? I've looked at hooks for WP-Cron, but got a little lost.

Additionally - is there a hook that fires once an auto-updated is complete? Our code is in source control, and I'm looking at ways to 'auto-commit' a new branch into our code after an update (rather than having to do it manually).

(The duplicate question doesn't provide any guidance into the hooks to check - simply suggesting to edit the Database - it also talks about WP Cron being fired 'on load' - rather than running on a dedicated cron).

Cheers, Darren

  • 1
    A simple time check in the callback should it, but I'd just turn off the auto-update. It is a bit crazy, IMHO, to run updates "now and then whenever an update comes out" on a production server in a business environment.
    – s_ha_dum
    Jun 5, 2015 at 17:35
  • possible duplicate of Alter how often WordPress Auto-Updates Plugins
    – Howdy_McGee
    Jun 5, 2015 at 18:50
  • @s_ha_dum ... we run a LOT (1,000+) WordPress websites. Keeping them all up to date after a security issue is a major logistical challenge! We decided to take the approach of auto-update minor versions, with automated monitoring where needed. If an update causes an issue, we simply rollback to the previous version. We also don't use many "off the shelf" plugins (or plugins in general). We'd prefer a site to be secure (but broken), than insecure (but working).
    – Darren
    Jun 8, 2015 at 9:46

3 Answers 3


This one is actually surprisingly simple; add this to your wp-config.php file and all automatic updates will be blocked when outside of the specified hours:

// Suspend updates when outside of business hours, 9:00 AM to 5:30 PM
$updates_suspended = (date('Hi') < 0900 || date('Hi') > 1730);

define( 'AUTOMATIC_UPDATER_DISABLED', $updates_suspended );

You can also use these other constants and filters to control which automatic updates are allowed to run if you need to make this more specific.

Make sure you use the server timezone when you set this. The function date() might be configured to use a timezone that is different from your local timezone.


Based on "BenCole" answer:

date() is affected by runtime timezone changes which can cause date/time to be incorrectly displayed. better to use WordPress native current_datetime() that "retrieves the current time as an object with the timezone from settings".

        $current_time = current_datetime()->format( 'Hi' );

        $disable_updater = ( $current_time < 900 || $current_time > 1730 );

        define( 'AUTOMATIC_UPDATER_DISABLED', $disable_updater );
  • 1
    $disable_updater is always true. Should be && not || Aug 18, 2023 at 14:04
  • @johnnycraig You're right! edited, thanks.
    – iohnatan
    Sep 6, 2023 at 18:31
// An example to allow plugin auto update between "friday 6pm et monday 12am" :
$updates_suspended = !((date('N') == 5 && date('G') > 17) || in_array(date('N'), array(6,7)) || (date('N') == 1 && date('G') < 12)(;
define( 'AUTOMATIC_UPDATER_DISABLED', $updates_suspended );

the value of date('N') is an integer who is the day of the week (1 to monday and 5 to friday) the value of date('G') is an integer who is the hour of day If you just want handle with hour of day, use only date('G') Example : to allow update plugin auto every day only after 11pm and before 6am :

$updates_suspended = !((date('G') < 6 || date('G') > 22));
define( 'AUTOMATIC_UPDATER_DISABLED', $updates_suspended );

This code goes in wp-config.php, it have been tested and it works.

More details on dates here : https://www.php.net/manual/fr/function.date.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.