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);
}
}
2
solved Create custom field on post draft or publish?