Hi Long,
Here is the callback function hook :
add_action( 'rwmb_logbook_after_save_post', 'update_logbook_post_title' );
function update_logbook_post_title( $post_id ) {
// Get the field value
$patient_id = rwmb_meta( 'post-patient', '', $post_id );
$service_id = rwmb_meta( 'post-service_reanimation', '', $post_id );
// On vérifie si le slug est un uuid
// Autrement on génère un uuid pour le slug et pour le code d'invitation
$post_slug = get_post_field( 'post_name', get_post() );
if (!wp_is_uuid($post_slug)) {
$uuid = wp_generate_uuid4();
$my_post = array(
'ID' => $post_id,
'post_title' => $service_id . '-' . $patient_id,
'post_name' => $uuid
);
$uuidHiddenToken = wp_generate_uuid4();
update_post_meta($post_id, 'hidden-token', $uuidHiddenToken);
}
wp_update_post( $my_post );
}
I changed custom post type slug from "journal-de-bord" to "logbook".
With best regards,
Jerome