This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Ever wondered how to enable or disable major automatic updates in WordPress? No worries, I’m here to explain it in a simple way. Let’s dive into the allow_major_auto_core_updates filter hook!
allow_major_auto_core_updates Filter
Filters whether to enable major automatic core updates.
To use the allow_major_auto_core_updates filter, first register it using add_filter
. You can place this code into the functions.php
of your activated theme or in a custom WordPress Plugin.
We at WePlugins always prefer to create a custom WordPress Plugin while using hooks so nothing breaks when you update your WordPress Theme in the future.
In the example below, we define a function weplugins_modify_allow_major_auto_core_updates
which takes 1 parameter. We register it using add_filter
. The first parameter allow_major_auto_core_updates is the name of the hook, the second parameter weplugins_modify_allow_major_auto_core_updates is the name of the function to be called, the third parameter is the priority of calling the hook if the same hook is used multiple times, and the last parameter is the number of arguments (if any) to be passed in the registered function.
Sometimes, you need to remove a registered hook, so you can use remove_filter
to remove the allow_major_auto_core_updates filter.
Parameters
- $upgrade_major : (bool) Whether to enable major automatic core updates.
Below is the 1 parameter required to use this hook:
Live Example
Below is an example of how you can use this hook:
Example 1: Enable Major Auto Core Updates
Enable major automatic core updates for your WordPress site.
function weplugins_modify_allow_major_auto_core_updates($upgrade_major) { // Enabling major auto core updates return true; } // add the filter add_filter("allow_major_auto_core_updates", "weplugins_modify_allow_major_auto_core_updates", 10, 1);
Example 2: Disable Major Auto Core Updates
Disable major automatic core updates for your WordPress site.
function weplugins_modify_allow_major_auto_core_updates($upgrade_major) { // Disabling major auto core updates return false; } // add the filter add_filter("allow_major_auto_core_updates", "weplugins_modify_allow_major_auto_core_updates", 10, 1);
Example 3: Conditional Major Auto Core Updates
Enable or disable major automatic core updates based on certain conditions.
function weplugins_modify_allow_major_auto_core_updates($upgrade_major) { // Enable updates only if the site is not in maintenance mode if (!defined('WP_MAINTENANCE')) { return true; } return false; } // add the filter add_filter("allow_major_auto_core_updates", "weplugins_modify_allow_major_auto_core_updates", 10, 1);
To remove a hook callback, use the example below:
remove_filter("allow_major_auto_core_updates", "weplugins_modify_allow_major_auto_core_updates", 10, 1);
Please make sure to provide the same callback function name, priority, and number of arguments while removing the hook callback.
Contact Us
If you need any customization or run into issues using this hook, don’t hesitate to contact us. We’re here to help!
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.