Multiple WordPress installation sharing one user table

Recently my project required me to setup multiple WordPress installation and each WordPress installation does different thing. The only problem that i faced was to have a synchronize login between these three WordPress installation. Short to say, once a user has logged into the system, they will not have to do it again if they decide to proceed to the next WordPress installation.  There are a few great explanation on how this can be done even on WordPress forum. However, it seems like everyone faced a little problem of having to touch the core of WordPress in order for their user to access another WordPress installation without getting the message 'You do not have sufficient permissions to access this page.'.


Before i began, you will need to know certain things in order for WordPress to share user table across multiple WordPress installation.

  • All your WordPress installation must be within the same database
  • Each WordPress installation must have different prefix ( or else you are performing overwriting)
  • URL must be within the domain. Multiple domain will have problem authenticating an already logged in user although sharing user table is still possible.
  • WordPress installation version must be similar across the media you wished to share.

Enough of my crap. Let's start with something simple.

Sharing WordPress user table

Our objective here is to share WordPress table across sub domain. Although different domain will also work but your user will have to log in manually on each different domain WordPress installation. (i will explain later) The main thing you will need for each sub domain to use a single user table is to point all your WordPress installation towards one user table. In order to do that, you will have to edit your wp-config.php file on all your sub domain WordPress installation and place the following code into it.

13 thoughts on “Multiple WordPress installation sharing one user table

  1. Hi Clay, thanks for this. I'd been looking for a fix everywhere. I'm not sure exactly what you mean for me to change when you say "hardcode the prefix to the main domain to this instead". Does that mean change the line: "$wpdb->prefix . 'user_roles';" to "$wpdb-> 'user_roles';"

    Thanks for sharing this. I'll be posting about it when I'm sure I understand it.

  2. no means hardcode to
    instead of
    $wpdb->predix . 'user_roles'.

    You will need to change the $wpdb->prefix to the one similar to the main prefix user table that you used for sharing.

  3. Thanks! I think I'm still half asleep this morning. I did that and was still getting the "you do not have permission" error, so I went in and changed the database (thanks for that explanation!) and then installed the wp-orphanage plugin in case any new users are orphaned. I'll poke around in the capabilities file some more later to see if I can figure out what I did wrong.

  4. Sorry Clay, but the permissions problem persists even after following all your steps. I've got two WP 2.9.2 installs, and am trying to point blog #2 to blog #1. Adding custom tables and auth data to wp-config.php goes fine, and I can log in. But even after altering capabilities.php in blog #2, it tells me I don't have access.

    Also tried going into table wp_2_options and changing value 'wp_1_user_roles' to 'wp_2_user_roles'.

  5. @Daniel: My bad, you should change the one on _init_caps() instead of init(), changing prefix.'capability.php' instead of prefix. 'user_role'.

  6. To future readers, before Clay gets a chance to update:

    As mentioned, in wp-includes/capabilities.php, you need to edit _init() as described, replacing $wpdb->prefix . 'user_roles' with 'YOURPREFIX_user_roles'.

    But you ALSO have to edit _init_caps(), replacing $wpdb->prefix . 'capabilities' with 'YOURPREFIX_capabilities'

    Thanks Clay. Please update; it's the only working solution and I saw a lot of threads with people stuck - some citing your current post as 'not working.'

  7. Thanks Daniel. Please bear in mind that altering WordPress core code will means you will have to edit them again in every single WordPress version update or else it will not work.

    P.S: There are other alternatives rather than editing your core code 🙂

  8. Hi I'm abit confused on the instructions on how to get rid of the permission issue? I'm not to sure exactly what to edit and what areas to replace? Will this still work if we decide we don't want to integrate both the logins? i.e. just do the table sharing and edit the capabilities.php ??

  9. sorry forgot to mention the area i'm getting confused on is the part about editing 2 parts in capabilities.php... and also which prefix to place in there and do you also keep the wording capabilities in there with the prefix

  10. actually sorry for all the posts just got this working.... Daniels post confused me you only need to change the _init_caps() as mentioned by Clay not both

  11. The only issue i have now is that I can't seem to access the wp-admin on my second blog. i login to blog 1 which works, go to blog 2 and it shows me logged in, so i click on site admin and it takes me to a wordpress login area with my user name in there and empty password. So i add my password in and it just keeps going back to the same login screen... isn't saying my login details are wrong or anything .... also can you delete my first couple of posts?

  12. @nirok: Is there any plugin you have installed on your second blog that might be causing this? Try deactivate all other plugin to ensure that both your blog have been synchronous before activating the plugin will be advisable 🙂

  13. Hey i have it working now, the only issue is logging out of hte second blog doesn't log otu of the first blog however i don't think this will be an issue

Comments are closed.