Hi!
I need to set a random hexa code to each post and this code need to persist in database to future search. I have created a custom function to return a code, but now I need to know how to puts this code into de input text field of metabox if this code not exist.
My function:
function generate_my_own_code( $post_id ){
$post_type = get_post_type($post_id);
if ( "classified" != $post_type ) return;
$code = rwmb_meta('code', array(
'storage_type' => 'custom_table',
'table' => 'web_classified_meta',
));
if( empty($code) ):
$code = strtoupper(dechex(rand(0x000000, 0xFFFFFF)));
endif;
return $code;
}