Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use plugins_auto_update_enabled filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
April 2, 2023
5 minutes read

When working with WordPress, hooks are like those magic spells that let you customize your site without touching the core files. One such hook is the plugins_auto_update_enabled filter. This nifty filter lets you control whether plugins auto-update on your site. Let’s dive into how you can use it effectively!

Example 1: Enabling Auto-Updates for All Plugins

Want to ensure all your plugins stay up to date without lifting a finger? This example shows you how to enable auto-updates for all plugins effortlessly.

    function weplugins_modify_plugins_auto_update_enabled_defaults($enabled) { 
        // Let's make sure all plugins auto-update
        return true; 
    }
    add_filter("plugins_auto_update_enabled", "weplugins_modify_plugins_auto_update_enabled_defaults", 10, 1);
    

Example 2: Conditional Auto-Update

Perhaps you only want certain plugins to auto-update based on specific conditions. Here’s how you can achieve that.

    function weplugins_modify_plugins_auto_update_enabled_conditionally($enabled) { 
        // Auto-update only if the site is in maintenance mode
        if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE) {
            return true;
        }
        return $enabled; 
    }
    add_filter("plugins_auto_update_enabled", "weplugins_modify_plugins_auto_update_enabled_conditionally", 10, 1);
    

Example 3: Disabling Auto-Updates

Auto-updates can sometimes be a hassle. If you prefer to handle updates manually, here’s how you can disable them.

    function weplugins_disable_plugins_auto_update($enabled) { 
        // Turn off auto-updates for all plugins
        return false; 
    }
    add_filter("plugins_auto_update_enabled", "weplugins_disable_plugins_auto_update", 10, 1);
    

If you ever need to remove a filter, you can simply use remove_filter. Remember to provide the same callback function name, priority, and number of arguments as when you added it.

Access Premium WordPress Plugins

Need help customizing your WordPress site or working with hooks like this? Contact Us and our team will be happy to assist you!

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

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.