I've been trying to set a scheduled publish date using an ACF field. I'm trying to make a custom backend editor for computer-illiterate clients to create and edit posts. I believe that the default method of scheduling posts is too complicated for them to work with.
While I've been able to set the custom publish date using this method, the resulting post is set as published instead of scheduled ( it says "published on [future date]").
Even stranger, going to the post list, hitting "quick edit" on this new post, and updating it there, without editing anything, will change the post to scheduled, like I want it to be.
Here is what I'm using to set the publish date field:
add_action('save_post', 'change_content');
global $post;
global $wpdb;
function change_content($post_id) {
if (get_post_type() == "events"){
$datefield = get_post_meta($post_id,'post_date',true);
$post_date = date("Y-m-d H:i:s", strtotime($datefield));
$my_post = array();
$my_post['ID'] = $post_id;
$my_post['event_date'] = $post_date;
}
remove_action('save_post', 'change_content');
wp_update_post( $my_post );
add_action('save_post', 'change_content');
}
Is there a way to set the post to scheduled with just one click of "save post" using this strategy, or will I need to find an alternate method?