2 Fixed code.
source | link

Add an array and choose one for the value.

add_action('draft_post', 'add_custom_field');
function add_custom_field($post_ID) {
    global $wpdb;
    if(!wp_is_post_revision($post_ID)) {

        $colors = array('white', 'green', 'blue');

        add_post_meta($post_ID, 'random_color', array_rand$colors[array_rand($colors, 1)], true);
    }
}

Add an array and choose one for the value.

add_action('draft_post', 'add_custom_field');
function add_custom_field($post_ID) {
    global $wpdb;
    if(!wp_is_post_revision($post_ID)) {

        $colors = array('white', 'green', 'blue');

        add_post_meta($post_ID, 'random_color', array_rand($colors, 1), true);
    }
}

Add an array and choose one for the value.

add_action('draft_post', 'add_custom_field');
function add_custom_field($post_ID) {
    global $wpdb;
    if(!wp_is_post_revision($post_ID)) {

        $colors = array('white', 'green', 'blue');

        add_post_meta($post_ID, 'random_color', $colors[array_rand($colors, 1)], true);
    }
}
1
source | link

Add an array and choose one for the value.

add_action('draft_post', 'add_custom_field');
function add_custom_field($post_ID) {
    global $wpdb;
    if(!wp_is_post_revision($post_ID)) {

        $colors = array('white', 'green', 'blue');

        add_post_meta($post_ID, 'random_color', array_rand($colors, 1), true);
    }
}