WP_Error could not be converted to string
I try to add an existing user to a blog with the function add_user_to_blog($blog_id, $user_id, $role)
. The code I use gives me:
Catchable fatal error: Object of class WP_Error could not be converted to string in C:\wamp64\www\wordpress\wp-includes\ms-functions.php on line 206.
What do I need to do to make this work?
This is my code:
$domain = "";
$path = "localhost/wordpress/wp_4";
$title = "WP_4";
$user_id = 1;
$network_id = get_main_network_id();
$role = 'editor';
$new_blog_id = wpmu_create_blog($domain, $path, $title, $user_id, $network_id);
add_user_to_blog($new_blog_id, $network_id, $role);