post to subcategory and parent in wp_insert_post

The problem is, you can’t make an array like that in PHP. Trying to cast a string that contains a comma separated list as an array just produces an array with a single value–your comma separated string.

You want to use php’s explode function to create the array. It takes a string an splits it into a bona fide array based on an arbitrary delimiter (in your case, we’ll use a comma).

Try something like this:

if(isset($_POST['new_post']) == '1') {
    $post_title = $_POST['post_title'];
    $arr_post_category = explode(',',$_POST['cat']); // EXPLODE!
    $post_content = $_POST['post_content'];
    $new_post = array(
          'ID' => '',
          'post_author' => $user->ID, 
          'post_content' => $post_content,
          'post_title' => $post_title,
          'post_status' => 'publish',
          'post_category' => $arr_post_category // NOW IT'S ALREADY AN ARRAY

        );

    $post_id = wp_insert_post($new_post);

    // This will redirect you to the newly created post
    $post = get_post($post_id);
    wp_redirect($post->guid);
}