Using WordPress ‘allow_major_auto_core_updates’ PHP filter

The allow_major_auto_core_updates WordPress PHP filter controls whether major automatic core updates are enabled or not.

Usage

add_filter('allow_major_auto_core_updates', 'your_custom_function');
function your_custom_function($upgrade_major) {
    // your custom code here
    return $upgrade_major;
}

Parameters

  • $upgrade_major (bool): Whether to enable major automatic core updates.

More information

See WordPress Developer Resources: allow_major_auto_core_updates

Examples

Enable major auto core updates

Enable all major automatic core updates.

add_filter('allow_major_auto_core_updates', 'enable_major_auto_core_updates');
function enable_major_auto_core_updates($upgrade_major) {
    return true;
}

Disable major auto core updates

Disable all major automatic core updates.

add_filter('allow_major_auto_core_updates', 'disable_major_auto_core_updates');
function disable_major_auto_core_updates($upgrade_major) {
    return false;
}

Enable major auto core updates only for specific version

Enable major automatic core updates only if the current version is less than 6.0.

add_filter('allow_major_auto_core_updates', 'specific_version_major_auto_core_updates');
function specific_version_major_auto_core_updates($upgrade_major) {
    $current_version = get_bloginfo('version');
    return version_compare($current_version, '6.0', '<');
}

Enable major auto core updates only for specific users

Enable major automatic core updates only for users with a specific capability.

add_filter('allow_major_auto_core_updates', 'user_capability_major_auto_core_updates');
function user_capability_major_auto_core_updates($upgrade_major) {
    return current_user_can('manage_options');
}

Enable major auto core updates only on weekdays

Enable major automatic core updates only on weekdays (Monday to Friday).

add_filter('allow_major_auto_core_updates', 'weekday_major_auto_core_updates');
function weekday_major_auto_core_updates($upgrade_major) {
    $today = date('N');
    return $today >= 1 && $today <= 5;
}