Я работаю над приложением, в котором есть форма публикации, которая сопоставляет наставников по усыновлению с подопечными.Это в Wordpress / PHP / MySQL / ACF (расширенное настраиваемое поле).
После отправки формы я не могу получить post_id для этого сообщения, поэтому могу сохранить поле ACF "title" дляэкран со списком всех совпадений.
Нужно ли мне извлекать $post_id
этой формы, когда я "вне цикла"?И как мне это сделать?
function match_post_title_auto( $post_id ) {
// get mentor & new mentee user array
$mentee = get_field('match_mentee', $post_id);
$mentor = get_field('match_mentor', $post_id);
$title = ' Mentor: ' . $mentor['display_name'] . ' and Mentee: ' . $mentee['display_name'];
$postdata = array(
'ID' => $post_id,
'post_title' => $title,
'post_type' => 'match'
);
wp_update_post( $postdata );
return $value;
}
var_dump($post_id); //returns NULL
//what do I put here to get that `post_id`? Thanks!
add_action('acf/save_post', 'match_post_title_auto', 10, 1);