How to use `wp_insert_user` & `wp_insert_post` simultaneously without `headers already sent` error?

The header problem is actually this problem:

Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in /home/wp-includes/wp-db.php on line 885

Warning: mysql_real_escape_string() expects parameter 1 to be string, object given in /home/wp-includes/wp-db.php on line 885

You are getting those errors because somewhere you are sending an object when you shouldn’t be. When that error prints it sends content to the browser before the headers are sent, so when the headers actually are sent you get an error.

I am not spotting where you are sending an object though, sadly. var_dump all of your variables and you should find the problem.

For example.

$new_post = array(
    'post_title'    =>  'Project',
    'post_status'   =>  'draft',
    'post_type'     =>  'project',
    'post_author'   =>  $user_id,
    'business_name' =>  $business_name,
    'business_city' =>  $business_city,
    'business_state' => $business_state,
    'methodgroup'   =>  $methodgroup );

var_dump($new_post);