I have 2 Wordpress installation: siteA and siteB. Each installation have their own wordpress database: databaseA for siteA and databaseB for siteB.

What I want is users on siteA can connect on siteB. I can't use CUSTOM_USER_TABLE beacause is 2 separate databases. However the database are hosted on the same server. So, how can I use the users table of siteA for siteB with my configuration?

  • you need to create APIs
    – Aftab
    Mar 15, 2017 at 14:06
  • You cannot without writing your own custom plugin. And even then it wont be easy and you'll have problems making it secure. CUSTOM_USER_TABLE solves a similar use-case but requires both WP installations to use the same database instance but different db prefixes.
    – user42826
    Mar 15, 2017 at 15:30
  • I know for CUSTOM_USER_TABLE using the same database but different db prefixes. That's the big problem... I have 2 databases, not just one.
    – Tidjy
    Mar 15, 2017 at 17:46

6 Answers 6


It's not possible in Wordpress to have shared users between 2 separates installations on 2 separated databases.

It could be possible just by hardcoding:

  1. hardcode WP_User class connect to other database and retrieve users from there
  2. hardcode get_metadata() function, that for wp_usermeta table connect to other database and retrieve users from there

but mentioned solution is not recommended of course, because it's not updateproof.


Merge the database content via WPRSS Import/export in a Multisite installation, one install, one maintenance and a default option to share users about the two sites. So you need no 3th party plugins and use different sites with different domains in one installation.


  • Maintenance, one-time upgrade
  • Shared Plugins, Themes
  • Shared Users
  • Quick Access To Many Blogs
  • Advanced settings
  • Standard, no 3th party plugins, changes necessary
  • can you setup a woocommerce with some configuration and another woocommerce with another different configuration in every site? Apr 13, 2021 at 19:52
  • 1
    Yes, you can activate WooCommerce in each site of the Network.
    – bueltge
    Apr 14, 2021 at 6:01

This ACTUALLY WORKS for me, but hey, warning and disclaimer first: Do this at your own risk.

It was pretty simple. Just "share" relevant tables between databases using views. I'm on MySQL / MariaDB so you should modify these statements if you're using a different DBMS.

USE siteB;
ALTER TABLE wp_users RENAME TO wp_users_bak;
ALTER TABLE wp_usermeta RENAME TO wp_usermeta_bak;
CREATE VIEW wp_users AS SELECT * FROM siteA.wp_users;
CREATE VIEW wp_usermeta AS SELECT * FROM siteA.wp_usermeta;

Keep in mind you have to use the same set of user-related plugins or you'll likely run into problems soon.


you can do it by making changes in wp_config file of site B On site A, let’s say it uses the ‘wp_1_’ table_prefix. For site B, you need to change the prefix from $table_prefix = ‘wp_1_’;


$table_prefix = ‘wp_2_’;

In Site B's config file add these codes:

define(‘CUSTOM_USER_TABLE’, ‘wp_1_users’);

define(‘CUSTOM_USER_META_TABLE’, ‘wp_1_usermeta’);

Also replace the salt keys in wp-config file of site A to site B

  • I don't think this would work with different databases but it may work with different prefixes.
    – Andy Gee
    Jul 31, 2018 at 7:51

Yes it's possible, despite the answers above. If you want to keep the websites completely separated, you can with WP Remote Users Sync (disclaimer: I am the author of the plugin)

Edit - to elaborate on the context and method used as asked in comments:

The way it works is that each time there is a change in user data (login, logout, create, update, delete, roles, password, metadata, using WordPress hooks and by redefining pluggable functions), a call is made to all registered remote sites (using a <script> tag for login and logout, so that cookies can be shared, and wp_remote_post in all other cases) using a specific endpoint (my-website.com/wprus/[action_name]). Then, on the remote site, the calls are listened and caught, the data is parsed, and the users are synced.

What sets this plugin apart from what already exists is the security layers in place: Communications are encrypted with single use initialization vectors, hmac-signed, token-validated and IP-validated to make the process as secure as possible.

What pushed me to implement it is that either the solution did not exist, or even commercial solutions out there were not suitable (the most popular and biggest offender being Share Logins Across Multiple Sites which is up to 250 USD per year and yet vulnerable in many ways, worst of which being iframe injection, but more info on that is worth its own dedicated post).

Syncing websites using separate domains, databases, and servers (and more so with secure token exchange) also means that there is an unavoidable marginal performance overhead for each user-related operation for each connected remote site (remote calls).

  • Since you have created a plugin for this, can you please post the relevant code here? You can still keep the plugin link, but without the relevant code posted locally, the external content can go offline/get removed at some point, making this answer useless. Thanks! ;)
    – Christine Cooper
    Mar 16, 2020 at 11:06
  • @ChristineCooper the code base is at least 15,000 lines of code spread into several files, I don't think that's possible. It is also available on Github
    – froger.me
    Mar 18, 2020 at 5:46
  • In this case, could you give a rundown of how the code is setup? As in, what the approach is. This way, your answer an work as an inspiration at the very least for someone else who was looking to code this themselves - but needed a helping mind. =)
    – Christine Cooper
    Mar 18, 2020 at 8:40

I was also thinking about doing this. So instead of having 2 different databases, you'd have just the one. And I know the table prefix can be different. So like wp_12 & wp_21 But I guess you need both salts to be the same on both sites?

I think with their issue is that it has 2 seperate DB's. So it would be best for them to make a new DB, and export the other 2 and import them into the new database. But that's providing that the table prefix is different for each site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.