carhop__carhop-theme__DEV/includes/equipe.php
2025-11-25 15:15:11 +01:00

25 lines
574 B
PHP

<?php
add_action('acf/save_post', 'carhop_save_equipe_post');
function carhop_save_equipe_post($post_id)
{
$post_type = get_post_type($post_id);
if ($post_type == 'equipe') {
$first_name = get_field('first_name', $post_id) ?? '';
$last_name = get_field('last_name', $post_id) ?? '';
$full_name = $first_name . ' ' . $last_name;
if ($full_name && $full_name != '') {
$post_slug = sanitize_title($full_name);
wp_update_post(array(
'ID' => $post_id,
'post_title' => $full_name,
'post_name' => $post_slug
));
}
}
}