I have tried this, but it does’t work.. post goes to draft only.
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
// check if this is to be a new post
if( $post_id != 'new' ) {
return $post_id;
};
// is checkbox field checked?
if (isset($_POST['acf']['field_601ec86a16f23'])) {
$status = 'draft';
} else {
$status = 'publish';
}
// Create a new post
$post = array(
'post_status' => $status,
'post_type' => 'post',
'post_title' => true,
);
// insert the post
$post_id = wp_insert_post( $post );
// return the new ID
return $post_id;
};