Can’t set custom taxonomy terms via custom form

Have you tried wp_set_object_terms? …which needs to be placed after your call to wp_insert_post as it requires the post ID in order to attach the correct terms, to the right taxonomy with the right post.

//add_action('plugins_loaded', 'newpost'); # will not work, user not authenticated

add_action('init', 'newpost'); // will work, user authenticated
function newpost() {
    if (isset($_POST['new_post']) == '1') {
        $post_title = $_POST['posttitle'];
        $post_content = $_POST['postcontent'];
        $taxonomy = 'cars'; //change accordingly...
        $terms = $_POST['tax_terms']; //change accordingly... 
        $new_post = array(
            'ID' => '',
            'post_author' => 1,
            'post_type' => 'cars',
            'post_content' => $post_content,
            'post_title' => $post_title,
            'comment_status' => 'closed',
            'ping_status' => 'closed',
            'post_status' => 'publish',
        );

        $post_id = wp_insert_post($new_post);

        //$terms can be an array of term IDs/slugs
        //$taxonomy is your taxonomy name, e.g. cars
        wp_set_object_terms( $post_id, $terms, $taxonomy );
    }
}

tech