Support

Account

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);