Home › Forums › General Issues › Use Date/Time picker as post publication date › Reply To: Use Date/Time picker as post publication date
OK – with the below code $post_id is echoed as ‘8’ – which is NOT the id number of the draft post (when i look at the link in admin), and $acfDate echoes nothing, I guess because the correct post id is not being obtained
function my_acf_save_post( $post_id ) {
global $post;
$post_id = $post->ID;
$acfDate = get_field('field_5a4cd9975f9a7', $post_id);
//Test if you receive the data field correctly:
echo $post_id;
echo $acfDate;
exit (-1);
$my_post = array();
$my_post['ID'] = $post_id;
$my_post['post_date'] = $acfDate;
wp_update_post( $my_post );
}
add_action('acf/save_post', 'my_acf_save_post', 20);
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.