Using WordPress ‘allow_dev_auto_core_updates’ PHP filter

The allow_dev_auto_core_updates WordPress filter allows you to control whether to enable automatic core updates for development versions.

Usage

add_filter('allow_dev_auto_core_updates', 'your_custom_function_name');
function your_custom_function_name($upgrade_dev) {
    // your custom code here
    return $upgrade_dev;
}

Parameters

  • $upgrade_dev (bool): Whether to enable automatic updates for development versions.

More information

See WordPress Developer Resources: allow_dev_auto_core_updates

Examples

Enable automatic updates for development versions

Enable automatic updates for development versions of WordPress.

add_filter('allow_dev_auto_core_updates', 'enable_dev_auto_updates');
function enable_dev_auto_updates($upgrade_dev) {
    return true;
}

Disable automatic updates for development versions

Disable automatic updates for development versions of WordPress.

add_filter('allow_dev_auto_core_updates', 'disable_dev_auto_updates');
function disable_dev_auto_updates($upgrade_dev) {
    return false;
}

Enable automatic updates for development versions only on specific weekdays

Enable automatic updates for development versions only on Mondays and Wednesdays.

add_filter('allow_dev_auto_core_updates', 'enable_dev_auto_updates_on_specific_days');
function enable_dev_auto_updates_on_specific_days($upgrade_dev) {
    $current_day = date('N'); // Get current weekday as integer (1 for Monday, 7 for Sunday)

    // Enable updates only on Mondays and Wednesdays
    if ($current_day == 1 || $current_day == 3) {
        return true;
    } else {
        return false;
    }
}

Enable automatic updates for development versions based on site option

Enable automatic updates for development versions only if a specific site option is set.

add_filter('allow_dev_auto_core_updates', 'enable_dev_auto_updates_based_on_option');
function enable_dev_auto_updates_based_on_option($upgrade_dev) {
    // Check if the site option 'enable_dev_updates' is set to true
    if (get_option('enable_dev_updates') == 'true') {
        return true;
    } else {
        return false;
    }
}

Enable automatic updates for development versions based on user role

Enable automatic updates for development versions only for users with the ‘administrator’ role.

add_filter('allow_dev_auto_core_updates', 'enable_dev_auto_updates_for_admins');
function enable_dev_auto_updates_for_admins($upgrade_dev) {
    $user = wp_get_current_user();

    // Check if the current user has the 'administrator' role
    if (in_array('administrator', $user->roles)) {
        return true;
    } else {
        return false;
    }
}