There are few problems with your code.
First of all, let’s see at wpmu_create_blog
function:
wpmu_create_blog(
string $domain,
string $path,
string $title,
int $user_id,
array $meta = array(),
int $network_id = 1
)
So you use it incorrectly. It’s 5th argument is $meta
and you put $network_id
in there…
Another problem is that this function can return int
(the ID of new site) or WP_Error if some error occured.
You ignore that and assume it always ends with success. And that is causing your error – function returns WP_Error
and you treat it as int
.