I use this code in my template
<?php acf_form(array(
'post_id' => 'new_post',
'new_post' => array(
'post_type' => '',
'post_status'=> 'publish',
'post_title' => $_POST['acf']['field_5882557e92006'].' - '.$_POST['acf']['field_5882557e9207c'].' - '.get_cat_name( $_POST['acf']['field_588713c7a61d9'] ), // Post Title ACF field key
'post_category' => $_POST['acf']['field_588713c7a61d9'], // Post Category ACF field key
),
'field_groups' => array(98), // Create post field group ID(s)
'form' => true,
'html_before_fields' => '',
'html_after_fields' => '',
'submit_value' => 'Submit Post',
'updated_message' => 'Saved!',
'uploader' => 'wp',
'return' => '/'
)); ?>
…and that in my function.php
function acf_review_before_save_post($post_id) {
if (empty($_POST['acf']))
return;
$_POST['acf']['_post_title'] = get_cat_name( $_POST['acf']['field_588713c7a61d9'] ).' - '.$_POST['acf']['field_5882557e92006'].' - '.$_POST['acf']['field_5882557e9207c'];
$_POST['acf']['_post_category'] = $_POST['acf']['field_588713c7a61d9'];
return $post_id;
}
add_action('acf/pre_save_post', 'acf_review_before_save_post', -1);
?>
…and all work very well except for the _post_category.
I whant to change the real category of the post but it dosen’t change after saving.
What am I wrong?
Thanks!