<?php
# Load WordPress barebones
define( 'WP_USE_THEMES', false );
require( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
# Multisite domain
$main_site = 'example.com';
# Type of Multisite
$subdomain_install = false;
# URL param activated
if( isset( $_GET['new-site'] ) )
{
# Create a new user
$rand_number = rand( 1, 2000 );
$username = 'user-' . $rand_number;
$password = 'fake-password';
// $password = wp_generate_password( 12, false );
$email = "[email protected]";
$user_id = wpmu_create_user( $username, $password, $email );
// wp_new_user_notification( $user_id, $password );
# Create site
if( $subdomain_install )
{
$newdomain = "{$_GET['new-site']}.$main_site";
$path = '/';
}
else
{
$newdomain = $main_site;
$path = "/{$_GET['new-site']}/";
}
$title = $_GET['new-site'];
$blog_id = wpmu_create_blog( $newdomain, $path, $title, $user_id ,
array( 'public' => 1 ) );
echo "New blog with ID = $blog_id";
}
else
echo 'Add to the URL: <b><tt>?new-site=NAME_OF_THE_SITE</tt></b>';
]]>This looks like a bug in the wpmu_create_blog() function. Shouldn’t blog options be applied before dummy contents are injected? But no matter if this is a bug or not, how can I fix this error? I have made sure the main blog uses the correct timezone, and the Apache time is correct as well. What am I missing. I also tried update_site_option() before calling wpmu_create_blog(), which didn’t help.
You help is very appreciated!
]]>i would like to create a new blog using my plugin.
The following lines of code just result in “Fatal error: Call to a member function init() on a non-object in /wp-admin/includes/upgrade.php on line 293” .
But when i look into my blog overview the new blog has been added successfully..
After refreshing my website the error message is not visible anymore.
$name = 'testblog';
$title = 'this is my testblog';
$user_id = '1';
wpmu_create_blog($current_site->domain, $current_site->path . $name .'/', $itle, $user_id);
So there is only an error message when wpmu_create_blog is executed.
Do u know why? :S
Thanks a lot!
I try to use the function wpmu_create_blog multiple times in a script.
When i run the script, it creates only one blog, the other ones are ignored.
Is this a bug?
I use WordPress 3.0
]]>