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

How to use allow_dev_auto_core_updates filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
May 29, 2023
5 minutes read

When working with WordPress, you might come across various hooks that can help you customize your site efficiently. One such hook is the allow_dev_auto_core_updates filter. This hook determines whether to enable automatic core updates for development versions. It’s often recommended to handle such hooks through a custom WordPress Plugin to ensure nothing breaks during theme updates.

To use the allow_dev_auto_core_updates filter, you need to register it using add_filter. You can place this code in the functions.php of your active theme or, preferably, in a custom WordPress Plugin.

Example 1: Applying the Hook

Below is an example of how you can use this hook. We define a function modify_allow_dev_auto_core_updates_defaults that takes one parameter $upgrade_dev, and we register it using add_filter.

    function weplugins_modify_allow_dev_auto_core_updates_defaults($upgrade_dev) { 
        // Update the $upgrade_dev variable according to your website requirements
        return $upgrade_dev; 
    }
    // add the filter
    add_filter( "allow_dev_auto_core_updates", "weplugins_modify_allow_dev_auto_core_updates_defaults", 10, 1 );
    

Example 2: Removing the Hook

To remove a hook callback, use the example below. Ensure you provide the same callback function name, priority, and number of arguments while removing the hook callback.

    remove_filter( "allow_dev_auto_core_updates", "weplugins_modify_allow_dev_auto_core_updates_defaults", 10, 1 );
    

Example 3: Using the Hook Conditionally

Sometimes, it’s necessary to apply conditions before enabling the automatic updates. Here’s how you can accomplish that:

    function weplugins_modify_allow_dev_auto_core_updates_defaults($upgrade_dev) { 
        // Example conditional update
        if ( some_custom_condition() ) {
            $upgrade_dev = true;
        } else {
            $upgrade_dev = false;
        }
        return $upgrade_dev; 
    }
    add_filter( "allow_dev_auto_core_updates", "weplugins_modify_allow_dev_auto_core_updates_defaults", 10, 1 );
    

Access Premium WordPress Plugins

Contact Us

If you’re having any trouble using this hook or need customization, feel free to contact us, and we’d 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.