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.
Related Posts:
- Uncaught Error: Call to undefined function wp_generate_attachment_metadata() @ wp-cron
- What happens when wp_cron is deactivated in WordPress?
- wp_schedule_single_event function not working
- How ( and mostly at what time ) can i prevent the alternate cron from running?
- Why is wp-cron only executing on page visit?
- Does using WP-cron make the site slower for the user?
- wp_schedule_single_event not working: cron job is triggered but nothing gets executed
- How does task scheduler plugin implements cron that is not dependent on page load request? [closed]
- How to set intervals in cron jobs?
- Switch from wp-cron to a server cron job
- What causes wp_schedule_single_event to fire off?
- WordPress cron job running more than once
- Cron: Update four post at Hour
- Activate Plugin Automatically After Set Time
- WP_CRON issue with UTC and local time
- Better way to run heavy scripts using WordPress database
- WordPress Cron function is not working
- WordPress crob job performance
- Adding custom cron_schedule prior to wp_schedule_event
- Hook automatic_updates_complete to autoupdate plugin
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- Update plugin from personal API
- Preventing a plugin from updating
- How wordpress detects a plugin update
- Avoiding plugin name collisions with WP updater
- WordPress Hook that will run when media file deleted
- Disallow a user to post in certain categories
- Multiple wp_schedule_event cron jobs in plugin cause multi-execution
- Plugins won’t auto-update on IIS
- Adding a form at the end of the content
- How can I add a custom meta value on file upload?
- How can I filter blog name?
- why does the add_action(‘the_content’) overwrite my page
- Fatal error: Class not found in
- Showing Notifications While Activating Plugin
- Woocommerce Shipping module available only for type of products [closed]
- Put code into body tags near top, using a plugin
- Hook before & after plugin / core update
- publish_post plugin hook doesn’t always pass $post->post_content
- get_plugins() doesn’t work after plugins_loaded
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- Randomize attachment IDs
- Are there hooks for WordPress updates?
- Pass info from functions.php to plugin
- Plugin activation hook in an abstract class
- How to make my plugin able to be updated from admin panel?
- Change permalink structure hidden button edit
- WordPress filter that hook after each action/filter hook
- When to use action hooks and plugins
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Gravity Forms plugin: How to use “gform_editor_js” action hook? [closed]
- After plugin options changed hook
- How make a php script run only with wp-cron
- Map a custom id to wordpress post id
- Calling plugin function inside custom plugin for onclick event
- get current date + 90 days and checking every day
- How to get post ID with hooks publish_post, new_to_publish, etc
- Add sub menu page in your plugin
- how to change automatic placing of social plugins below content?
- Deactivate JS Script in Plugin Shortcode
- Check filter defined or not?
- Plugin Development – Functions or Hooks?
- Adding Plugin Assets to Header
- What are admin hooks
- How do I add $_SESSION[”] to my wordpress page?
- get_users(); Is an Undefined Function When Used in Cron Job
- How to use filter to disable adding a product to wishlist?
- WordPress: Add custom add_filter for custom functions
- WordPress cronjob get scheduled but function does not run
- Plugin scheduled event not working
- Function added to hook “new_to_publish” not executing – custom plugin
- Hook for plugin to insert into entry-meta
- Use a hook or filter, or overwrite this Gamipress function?
- Hook from plugin doesn’t fire up from external PHP script
- How to set plugin auto-update Enabled by default?
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- Randomize post (and page) IDs on generation
- save_post hook partly firing in update post
- Cron task gets removed from the schedule
- Show post object of any page in frontend
- How do I stop plugins and themes from getting updated in a new plugin?
- get_posts query results out of order but shows correct in php snippets plugin
- Use action, filter, or hook to append HTML to WordPress plugin function
- Passing function into add_action always returns the first argument
- Hook to display element as product on category page
- Is it possible to disable a theme programmatically?
- plugin not hooking to my custom hook
- wp_login_form() ignoring login_form action hook
- Modify a plugin’s content
- Plugin hook breaks new WP 4.0 media library grid view?
- Auto post with filling templates from external data and update periodical
- Variable scope in plugin outside loop [closed]
- Checking url from plugin [duplicate]
- WordPress Hooks : Where to place callbacks that repetitively yield the same effect?
- Suitable hook when creating, updating and deleting posts programmatically
- How to Replicate Elementor Licensing Model
- Change social icon in twenty twenty three theme
- is_user_logged_in() undefined at shutdown in plugin context