Register an account
E-mail will only be used to recover your login information
Wordpress

Share user database tables between two WordPress installations

One database, one user list, two blogs

In a recent project, I found myself having to share user tables between two separate WordPress installations. This is common in multi-lingual websites, but might just come in handy for you as well. I am assuming you already have a WordPress installation in place and are now installing a second one. You’ll need to open your first WordPress installation’s config.php file and copy the database configuration and paste it into the second. This allows both installations to use the same database.

Now we need to make sure that we don’t overwrite our content, so we’ll change the $table_prefix value to something unique like “wp2″.

$table_prefix = 'wp2_';

All we need to do now is grab the user tables by adding the following lines. This is assuming you left the tables prefix to “wp” when you installed WordPress the first time around.

define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');

Done. Install as usual and enjoy your shared user tables.

Notice

It’s been brought to my attention that by using this method, you would be unable to log in to the second installation by using the default administrator login. I’m looking at work-around solutions but for the time being, you should be able to create a new user with admin access that could exploit both installations.

How-to Wordpress

Comments be closed, matey

Sorry, no comments can be made on this post.

If you have something of value you can add to the discussion, please contact me and I will ammend it to the post. Otherwise, keep exploring my blog for a chance to offer your insight on various topics.

Your Ad Here
  1. johntra
    August 16, 2010 at 2:35 PM

    Hi, any idea how to share all tables except options – can we just use other table names for this?

  2. cdtoad
    August 21, 2010 at 1:41 AM

    This won’t work. One of the two blogs will then not let you in as admin.

  3. adan
    September 14, 2010 at 9:28 AM

    Trying to login from “shared user” blog using “master” user and usermeta table… after login… it shows this

    “You do not have sufficient permissions to access this page”

Get a Dropbox!