skip to Main Content
Menu

Share users between two blogs.

Ever needed to create a main wordpress site with a subdomain (also wordpress site) but wanted to use the main wordpress sites’s mysql database and  user table?

Well here’s how..


The rule here is to have two different sets of prefixes (ex. main_ for the main site and sub_ for the subdomain site)

Put them both in the same database with different prefixes. Then choose one of them to be the master user table. Then do this in both wp-config.php files:

define(CUSTOM_USER_TABLE,’main_users’);
define(CUSTOM_USER_META_TABLE,’main_usermeta’);

Note: default prefix is “wp_”.. we just used “main_” as an example and you can use any other prefix you prefer.

In other words, you designate the user table from ONE installation as the master user table which will be used by the other installations instead of their own user table. This PHP code must go in the wp-config.php file in all the installations that you want sharing a single user table. You can have more than two installations set up the same way. Their tables must all be in a single database however.

For this to finally work.. you need to

in table wp_usermeta look for the following entries, at least for the admin account:

main_capabilities – a:1:{s:13:”administrator”;s:1:”1″;}
main_user_level  – 10

create the following records for the same user..

sub_capabilities – a:1:{s:13:”administrator”;s:1:”1″;}
sub_user_level – 10

disclaimer: This should only be done if you are familiar with and have phpmyadmin on your site or if  you are sure of your SQL. always back-up your database before trying anything.

Alphonse

Editorial Staff at ETN Multimedia is led by Alphonse Tan. Page maintained by Alphonse Tan

Back To Top