I’m trying to bulk-create a certain number of blogs:
$blog_count = 5;
$site = get_current_site();
while($blog_count > 0){
shuffle($words);
$blog_title = implode(' ', array_slice($words, 0, mt_rand(1, 3)));
$blog_domain = $blog_path = sanitize_key($blog_title);
if(domain_exists($site->domain, $site->path.$blog_path, $site->id)) continue;
$blog_id = wpmu_create_blog($site->domain, $site->path.$blog_path, $blog_title, 0, '', $site->id);
echo "Created - {$blog_id}";
$blog_count--;
}
And I cannot get the paths set up correctly on all blogs. In this case only 2 out of 5 blogs work correctly.
$site-domain
is “localhost”$site->path.$blog_path
is “/wpmutest/thenameoftheblog/”
(this is not a sub-domain install)
When I go and edit them, the “Update siteurl and home as well.” option is unchecked on the problematic blogs, and I cannot update it (it doesn’t change after I press save). It seems that the database tables are not getting created.
Am I doing something wrong here, or is this a bug?
Apparently a global variable is not properly updated. I found a fix based on blackriver’s reply here, it’s a little ugly but it works:
and
somewhere in the code that’s using this function.
If someone has a better solution please post it so I can accept an answer 🙂