One of the things I’ve always wanted to know how to do was create two separate WordPress installations but have the same users.
This turned out to be a lot easier than I thought it’d be all thanks to a WP support forum post on sharing user tables.
I’m actually using this at Theme Hybrid for some future parts of the site. So, this thing is being tested live.
How to share the same user tables
Note: I’ve tested this on WordPress 2.5, 2.6, and 2.7 (latest from trunk).
First, both installations of WordPress should probably be the same version.
Both installations should be within the same database (I’m not sure how/if this would work on separate databases).
I also recommend backing up your databases anytime you change code that might mess with it, but it shouldn’t be necessary.
Let’s suppose you have Blog A and Blog B. Blog A has been your main installation for a while, but you want to add a second installation with the same users (Blog B).
Let’s also suppose you’re using the default WordPress table prefix
wp_ for Blog A.
Blog B’s table prefix should be different. We’ll change it to something like this in Blog B’s
$table_prefix = 'blogb_';
In the same file, find this line:
/* That's all, stop editing! Happy blogging. */
Just above it, add:
define('CUSTOM_USER_TABLE', 'wp_users'); define('CUSTOM_USER_META_TABLE', 'wp_usermeta');
This tells Blog B’s installation that you want to use the user and usermeta tables from Blog A’s installation. However, the rest of Blog B’s content will come from its own unique tables.
Suggestions or comments
I don’t generally work a lot with databases, and I assume this is pretty easy for more advanced users. If there are easier ways to handle this, then I’d love to hear what you have in mind.
Otherwise, have fun with your two installations.