Or how to create a blog network with out WordPress Multi-User.
Almost 2 years ago, I was charged with the duty of building an integrated Blog network with WordPress, for the Parents Everywhere Network. WordPress MU wasn’t quite ready for prime time, as most plugins hadn’t been ported over, and documentation was sparse, and only the bravest of souls wanted to tangle with it. Remember, this was back before WP and MU development were in sync. So I had to come up with another way.
That’s when I ran across these little known wp-config.php keys: CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE. By setting these keys to the same values in all of your wp-config.php you can have multiple WordPress installs share the same user tables and essentially create a nearly-perfect single sign-on system for your blog network.
There are limitations, of course, but by and large the shared users table trick works like a charm. I’ll show you how to set it up yourself for some newly installed blogs. You can convert existing blogs over, but that takes more DB fiddling then I’ll go into in this article. The biggest limitation is that all of the blogs have to be installed in the same Database. However, they can be on different servers, as long as they can all talk to the same Database.
- First, install your primary blog as normal, and set your CUSTOM_USER* keys in your wp-config:
- Second, create the wp-config.php for your second blog, using the same DB Connection information. You also need to set AUTH_KEY, SECURE_AUTH_KEY, LOGGED_IN_KEY, NONCE_KEY, and the CUSTOM_USER* keys to the same value as the first. You will also need to set $table_prefix to a unique value.
- Install the second blog and instead of getting a random password for the admin user, it should tell you that it found the user and is using that password.
- Rinse and Repeat steps 2 and 3 until all blogs are successfully installed.
Now that all of the blogs are sharing the same user tables, your admin login will work on all of them, and remain the same, even when changing the password and other meta data (i.e. name, etc), but all other settings will remain distinct for all of the other blogs. However, if you allow (or force) users to sign up to comment or do other things on your blog, then you will run into the second limitation of this trick – users only get a Role assigned on the blog that they signed up on. Their account is in table and accessible to the other blogs, they just don’t have any privledges. In other words, they are orphans. This can be fixed manually in the User management screens, or automatically via a plugin.
The final limitation, and this isn’t the fault of WordPress but how the internet works, is that because your blogs are (probably) on separate domains, cookies can’t be shared between them easily and hence users will have to log-in to each blog they visit. A small price to pay for one of the cooler hidden features of WordPress.