[wp-hackers] creating blogs across several installs (Nuno Morgadinho)

Elizabeth Buckwalter elizabeth at slatetechpdx.com
Mon Apr 12 17:51:24 UTC 2010


> Message: 1
> Date: Mon, 12 Apr 2010 15:57:00 +0200
> From: Nuno Morgadinho <nuno.morgadinho at gmail.com>
> Subject: [wp-hackers] creating blogs across several installs
> To: wp-hackers at lists.automattic.com
> Message-ID:
>        <n2v5721607d1004120657keb43b5fyb7526ae4747ed5a9 at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I have 5 WPMU installs (with different IP addresses and domains). When
> the user signs-up and creates a blog I would like to additionally
> create a blog in each of the WPMU installs. I thought about two
> possible approaches for this:
>
> 1) write directly into the database (the installs all share the same
> database server)
> 2) make a http request to each MU that will then handle the request
> and write into the db
>
> Would you rather go for 1 or 2? And is there some work done already in
> this front of creating blogs across several installs?
>
> Thanks,
>
> --
> Nuno Morgadinho
> http://www.morgadinho.org
> http://twitter.com/morgadin
>



I'd go for a mix of 1 and 2)  I've made a (very very) custom plugin
for a client that adds a blog with all the appropriate setting, so he
doesn't have to the theme or pages, and can add the categories that
already exist to the new blog.  It uses to core switch_to_blog
function, which sets up all the tables and options, the kind of thing
that doesn't need to be rewritten.  But this plugin is in one install
and only deals with one install.

Which brings me to step 2.  You'd have to then pass the data to the
other install and tell it to run it's custom create a blog plugin.
the simplest would be calling your plugin through http request.

the first part of my plugin uses the standard code in the
wpmu-edit.php starting at around line 129 (wpmu trunk
http://xref.yoast.com/wpmu-trunk/nav.html?wp-admin/wpmu-edit.php.source.html#l129)

Then I use switch_to_blog in wpmu-functions.php around line 1297
(http://xref.yoast.com/wpmu-trunk/nav.html?wp-includes/wpmu-functions.php.source.html#l297)
to add my custom settings like the theme which is as easy as
update_option('current_theme', 'theme decscription');
update_option('template', 'theme name'); update_option('stylesheet',
'theme name');

There isn't an easy way to activate plugins if they have to create a
database table unforunately, as simply inserting the activated plugins
makes them active, but doesn't run their activation script.

HTH

Elizabeth Buckwalter


More information about the wp-hackers mailing list