FEATURE handling new carhiop member synchronisation
This commit is contained in:
parent
5d14c64fa8
commit
98f628a05a
|
|
@ -44,19 +44,74 @@ function dynamiques_save_auteurs_post($post_id)
|
||||||
{
|
{
|
||||||
$post_type = get_post_type($post_id);
|
$post_type = get_post_type($post_id);
|
||||||
|
|
||||||
if ($post_type == 'auteurs') {
|
if ($post_type !== 'auteurs') return;
|
||||||
$first_name = get_field('first_name', $post_id) ?? '';
|
|
||||||
$last_name = get_field('last_name', $post_id) ?? '';
|
|
||||||
|
|
||||||
$full_name = $first_name . ' ' . $last_name;
|
$is_carhop_member = $_POST['acf']['field_691c8279b6458'];
|
||||||
|
$carhop_member_id = $_POST['acf']['field_691c831e94029'] ?? null;
|
||||||
|
|
||||||
if ($full_name && $full_name != '') {
|
$first_name = null;
|
||||||
$post_slug = sanitize_title($full_name);
|
$last_name = null;
|
||||||
wp_update_post(array(
|
|
||||||
'ID' => $post_id,
|
if (!$is_carhop_member) {
|
||||||
'post_title' => $full_name,
|
$first_name = get_field('first_name', $post_id);
|
||||||
'post_name' => $post_slug
|
$last_name = get_field('last_name', $post_id);
|
||||||
));
|
}
|
||||||
}
|
|
||||||
|
if (isset($is_carhop_member) && isset($carhop_member_id)) {
|
||||||
|
switch_to_blog(1);
|
||||||
|
$first_name = get_field('first_name', $carhop_member_id);
|
||||||
|
$last_name = get_field('last_name', $carhop_member_id);
|
||||||
|
$comity = get_field('comity', $carhop_member_id);
|
||||||
|
|
||||||
|
write_log($comity);
|
||||||
|
|
||||||
|
// $membre_carhop = get_post($carhop_member_id);
|
||||||
|
// write_log($_POST['acf']);
|
||||||
|
// $description = get_field('description', $carhop_member_id);
|
||||||
|
// $comity = get_field('comity', $carhop_member_id);
|
||||||
|
// $email = get_field('email', $carhop_member_id);
|
||||||
|
|
||||||
|
|
||||||
|
// write_log($first_name);
|
||||||
|
// write_log($last_name);
|
||||||
|
// write_log($description);
|
||||||
|
// write_log($email);
|
||||||
|
|
||||||
|
$display_name = $first_name . ' ' . $last_name;
|
||||||
|
|
||||||
|
restore_current_blog();
|
||||||
|
|
||||||
|
update_field('comity', $comity, $post_id);
|
||||||
|
}
|
||||||
|
$full_name = $first_name . ' ' . $last_name;
|
||||||
|
if (isset($first_name) && isset($last_name) && isset($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
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_filter('acf/load_field/name=carhop_member', function ($field) {
|
||||||
|
|
||||||
|
$field['choices'] = [];
|
||||||
|
|
||||||
|
switch_to_blog(1);
|
||||||
|
$equipe_members = get_posts(array(
|
||||||
|
'post_type' => 'equipe',
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'orderby' => 'title',
|
||||||
|
'order' => 'ASC',
|
||||||
|
));
|
||||||
|
restore_current_blog();
|
||||||
|
|
||||||
|
foreach ($equipe_members as $equipe_member) {
|
||||||
|
$field['choices'][$equipe_member->ID] = $equipe_member->post_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $field;
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,17 @@ $profilePictureUrl = $profilePicture['url'] ?? '';
|
||||||
$profilePictureAlt = $profilePicture['alt'] ?? '';
|
$profilePictureAlt = $profilePicture['alt'] ?? '';
|
||||||
$description = get_field('description', $ID);
|
$description = get_field('description', $ID);
|
||||||
|
|
||||||
|
$is_carhop_member = get_field('is_carhop_member', $ID);
|
||||||
|
$carhop_member_id = get_field('carhop_member', $ID);
|
||||||
|
|
||||||
|
if ($is_carhop_member && isset($carhop_member_id)) {
|
||||||
|
switch_to_blog(1);
|
||||||
|
$description = get_field('description', $carhop_member_id);
|
||||||
|
restore_current_blog();
|
||||||
|
}
|
||||||
|
|
||||||
|
write_log($is_carhop_member);
|
||||||
|
|
||||||
$totalArticles = count_user_articles($ID, 'articles');
|
$totalArticles = count_user_articles($ID, 'articles');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user