Sorry I’ve been involved in some personal stuff the past few days 🙂
To be honest I’ve not used the acf_form in this sense before.
What seems strange to me is that you’re setting post_title, post_content and post_category by using $_POST values but if you’re sending the user to this form with just a button there wont be any $_POST variables like this.
The way I’d do it is to just have a taxonomy field on the posts which are mapping the post to the terms (categories) and then add it to the acf_form by setting it in the field_group. Then for the title and content you have built in parameters in acf_form to let users type into those.
<?php acf_form(array( 'post_id' => 'new_post', 'new_post' => array( 'post_type' => 'post', 'post_status'=> 'publish' ), 'field_groups' => array(317, 123), // 317 is your existing field group and 123 is a madeup which contains the taxonomy field. 'submit_value' => 'Submit Post', 'updated_message' => 'Saved!' )); ?>
You shouldn’t need to mess with $_POST parameters and filters.
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!
© 2022 Advanced Custom Fields.