PHP beginner here. Will the following code do what I've noted correctly?
//Random code generator
function random_string_func() {
//Hash generator
$generated_hash = md5(uniqid(rand()));
//get all existing hashes and store them into an array
$existing_hashes = FrmEntryMeta::get_entry_metas_for_field(198, '', '', array()); //change 198 to the ID of the date field
//Check if the newly generated hash exists in WP database
if(in_array($generated_hash, $existing_hashes)){
//If yes, generate a new hash
$generated_hash = md5(uniqid(rand()));
}
return $generated_hash;
}
add_shortcode( 'random_string', 'random_string_func' );