multi-blog

Ever get tired of installing and setting up WordPress yet again so you can show a client a theme in development? Why yes, there is an easier way.

Enter WordPressMU, the multi-user, multi-blog version of WordPress which will soon be merged into the core. For those of you ready to jump-start some development, read on.

Installing WPMU is a slightly different process than regular WP. Basically, don’t edit the config file. Let the installer run. For the purposes of this tutorial, pick a subdirectory installation to give you client blogs in the format of yourdevsite.com/client1/.This way, we won’t have to tinker with the server to enable wildcard subdomains.

site-admin-menuNow that we are up and running, the biggest difference you will notice is that WPMU has an additional backend menu: the Site Admin menu. Upon installation a site admin is created, as well as the main site blog. This user has access to everything on the system, whether they are listed as a user on that blog or not. They are a Super User. Get familiar with the site admin menus, as this is where you enable some sitewide features, add new blogs, edit some member blog details, and generally do some admin work.

There are two sub-menu items disabled: the theme editor and the plugin editor. This is mainly because on a live site, when used as a free blog host, this can be really dangerous. One wrong edit to a plugin and you bring down everyone’s blog. One oops to a theme and it affects everyone using that theme. Since users can’t edit themes, you may want to make extensive use of theme options pages, since they are set on a blog by blog basis.

Also in WPMU there is a multitude of code that gets stripped out by default. Think of how WordPress.com works; you’re essentially using the same software. Since you’re the one in charge and hosting it for a limited number of users, I’ll get into how we can workaround some issues.

The first thing you may want to do is pick a fairly sedate theme for the main blog and set a welcome page as the front page. It should only be seen by client or someone who just wanders by, so something brief is fine. You could also include a login widget in the sidebar, so clients have a way to login. I’m assuming here you’re setting up a complete new site, and not one where the main blog is in use.

Set your registration to closed. It is set this by default, so you’re good to go. This will keep out random people and sploggers trying to set up shop. A splog is the term for Spam Blog.

How Plugins Are Used in WPMU

There are two plugins folders under WPMU. One is the regular plugins folder, the other is called mu-plugins. This folder is for wpmu-specific plugins and any code placed in here gets executed automatically. It does not recognize plugins contained within subfolders; there must be a file in the main folder for it to run. Any plugin requiring activation will not work porperly if placed in this folder. Also, none of the mu-plugins will show up on a list in the admin area. If it adds a user menu, you will see it.

As for the regular plugins folder, this is shared across user blogs, so each blog has access to the same list of plugins. This is disabled by default but still viewable to Site Admins. The Plugins menu can be turend on under the Site Admin -> Options menu. Regular plugin settings will apply to that blog only. They do not apply sitewide unless the plugin was specifically built to work that way.

While there are quite a number of plugins that have issues with working under WPMU, some of these are being fixed, and other plugins work just fine. Enabling plugins on a blog-by-blog basis and having it specific to that blog works in most cases. The trouble usually comes up in sitewide activation, or getting global results from all blogs, because many regular WP plugins aren’t multi-blog aware. Your best bet is to try a few plugins that do the same thing, and ask around the forums or on twitter.

Plugins We Need for a Client Development Site

All of the plugins below go in the mu-plugins folder.

The More Privacy plugin will help you achieve privacy for your clients. It adds these privacy options to the two defaults:

    Blog Visibility

  • I would like my blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers and in public listings around this site.
  • I would like to block search engines, but allow normal visitors
  • I would like only logged in users to see my blog.
  • I would like only logged in users who are registered subscribers to see my blog.
  • I would like only administrators of this blog, and network to see my blog.

Only the first option will let Google crawl the blog.

New blog defaults – this little plugin adds some extra options to the Site Admin menu so every time you add a new blog, these defaults are already in place. The options included are everything on the blog’s options page, as well as the default theme. This can eliminate a couple of steps in setting up each new blog.

Unfiltered MU will allow everyone on the site to paste code like javascript or styling into posts or text widgets, as if they were an admin on a regular WordPress blog. It does not allow php code. You’ll still need to add allow php, if you really need it. You won’t see anything happen when you add it, but if you have tried saving a post in WPMU that has code, it will no longer get stripped out.

As we are working on a closed system, this is okay. All of the plugins I’ve mentioned above go in the mu-plugins folder, as we want these to run constantly.

Setting Up Each Client’s Blog

You can add new blogs to the system very easily. Visit Site Admin -> Blogs and at the bottom, simply fill out the blog name and admin email. I generally like to be the admin of each blog.

add-blogs

Add the client as a user to the site under Site Admin -> Users. Email them separately to let them know to expect the user/pass email. Now you have to add them as a user to their blog. You can do this in the backend of their blog (under the Users menu), or you can also add them under Site Admin -> Blogs, then hover over their blog until the edit menu appears underneath their name. Click to edit their blog details. On the right is a drop-down to add them to this blog. Pick their user level, depending. I find Editor is usually a good role. Click the button to save.

add-user

Working on Client Themes

When you add a theme to WPMU, it will show you a message that it needs to be activated sitewide. You may not wish to have all themes available in each blog’s Appearance menu, so here’s how to enable a theme for one blog.

Visit Site Admin -> Blogs and find the blog name in the list. Click to edit the details. On the right, you’ll see a list of disabled themes with checkboxes. Check the one you want to allow for just this blog, and save.

When working on themes, you may wish to just work on them offline, then upload the changes for the client to view. If you need to make minor changes, enabling the theme editor can be accomplished by editing /wp-admin/imcluded/mu.php file and comenting out at line 1216 as follows:

$pages = array( 'theme-editor.php', 'plugin-editor.php' );
foreach( $pages as $page ) {
if ( strpos( $_SERVER['PHP_SELF'], $page ) ) {
wp_die( __('Page disabled by the administrator') );
}
}

To comment this out, put a double-forwardslash at the beginning of the first line, like this: //

While this enables both the theme and plugin editors, they are still removed from the menu system. Save the following code as a php file and place it in the mu-plugins folder.

<?php
function ra_add_theme_editor_menu() {
global $submenu;
       $submenu['wpmu-admin.php'][] = array(__('Theme Editor'), 'edit_themes', 'theme-editor.php');
}
add_action('_admin_menu','ra_add_theme_editor_menu', 99);
?>

This adds the menu items back, but places them under the site Admin menu. If a client attempts to access the theme editor directly by typing it in, they will still be denied permission.

Now you have your very own exclusive client development site. Clients will be able to login to their development blog to check on progress, just as if it were a stand-alone blog. You’ll be able to move their theme after they approve it, and even Export any content used on the dev blog.

Enjoy this post? You should follow me on Twitter!