The MU forums have moved to

using wpmu_create_blog function (5 posts)

  1. synyster
    Posted 15 years ago #

    i'm trying to create blog within plugin, after look at the source code of wp-admin/wpmu-edit.php, i found out that wpmu_create_blog is the function to create blog. hence i test it with the simpliest form(with only one line in the plugin):

    $blog_id = wpmu_create_blog("", '/something/', 'something blog', 2, '', $current_site->id);

    my wpmu site is using format and there is a user with user id equal to 2. when i enable the plugin it gave me the following error:

    Fatal error: Call to a member function init() on a non-object in C:\wpmu\wp-includes\wpmu-functions.php on line 1361

    the blog is created, but with last update time equal to never and no users is for the blog.

    please someone help me out!

  2. synyster
    Posted 15 years ago #

    maybe i should change my question to how can i use script to create blogs (because i have a long list of users in a file and i want to create a script that will add those users and create a blog for them) ?

    anyone got any ideas? (like what kind of function i should be use)

  3. synyster
    Posted 15 years ago #

    got my problem sorted now. i need to use signup_create_blog_meta filter before using wpmu_create_blog function and might be need wpmu_activate_blog action after it.

  4. dgilmour
    Posted 15 years ago #

    I think you might be reinventing the wheel. Have a look at Totus's CSV2BLOG bulk blog site creator.

    If you are interested in manipulating the WordPress WPMU platform into creating thousands of blogs in one fatal swoop this will do the trick.

    Maybe you can build on that?

  5. synyster
    Posted 15 years ago #

    thanks for the link, i think i found a solution to my problem which is using wpmu_create_blog function.

    i think using wpmu_create_blog function is more effection then the plugin your point out, because after a look into the source of that plugin, it request wp-admin/wpmu-blogs.php to get the security key and then send data(security key, domain name, blog title and email) via post to the add blog form within wpmu-blogs.php.

    all this actions seems a bit complex when you have wpmu_create_blog function built-in(for create a blog only 3 lines of code is required) so for more blogs you just need a loop.

About this Topic

  • Started 15 years ago by synyster
  • Latest reply from synyster