Hi. I have got form created for members to publish post on front end. I am looking for way to make it possible to choose if you want to publish new post or save it as draft. I tried to look for solutions, but everything what I found didn’t work for me.
thank for help
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;
};