Using WordPress ‘allow_minor_auto_core_updates’ PHP filter

The allow_minor_auto_core_updates WordPress filter allows you to control whether minor automatic core updates should be enabled or not.

Usage

add_filter('allow_minor_auto_core_updates', 'your_custom_function_name');

function your_custom_function_name($upgrade_minor) {
    // your custom code here
    return $upgrade_minor;
}

Parameters

  • $upgrade_minor (bool) – Determines whether to enable minor automatic core updates.

More information

See WordPress Developer Resources: allow_minor_auto_core_updates

Examples

Disable minor auto updates

Disable all minor automatic core updates.

add_filter('allow_minor_auto_core_updates', 'disable_minor_auto_updates');

function disable_minor_auto_updates($upgrade_minor) {
    return false;
}

Enable minor auto updates

Enable all minor automatic core updates.

add_filter('allow_minor_auto_core_updates', 'enable_minor_auto_updates');

function enable_minor_auto_updates($upgrade_minor) {
    return true;
}

Enable minor auto updates for specific user roles

Enable minor automatic core updates only for users with a specific role.

add_filter('allow_minor_auto_core_updates', 'enable_minor_auto_updates_for_role');

function enable_minor_auto_updates_for_role($upgrade_minor) {
    if (current_user_can('manage_options')) {
        return true;
    }
    return false;
}

Disable minor auto updates during specific hours

Disable minor automatic core updates during specific hours of the day.

add_filter('allow_minor_auto_core_updates', 'disable_minor_auto_updates_hours');

function disable_minor_auto_updates_hours($upgrade_minor) {
    $hour = date('G');
    if ($hour >= 8 && $hour <= 20) {
        return false;
    }
    return $upgrade_minor;
}

Enable minor auto updates for specific themes

Enable minor automatic core updates only if a specific theme is active.

add_filter('allow_minor_auto_core_updates', 'enable_minor_auto_updates_for_theme');

function enable_minor_auto_updates_for_theme($upgrade_minor) {
    $current_theme = wp_get_theme();
    if ('Your Theme Name' === $current_theme->get('Name')) {
        return true;
    }
    return $upgrade_minor;
}