Multiple WP install with same users database

You can do the sharing of users fairly easily.

Basically, both sites would use the same database (set up in wp-config.php), but each would get it’s own, unique $table_prefix.

From there, you can specify custom user and user meta tables that are the same for each site.

<?php
// site 1 wp-config.php
$table_prefix = 'site1_';
define('CUSTOM_USER_TABLE', 'custom_users');
define('CUSTOM_USER_META_TABLE', 'custom_usermeta');

For site two…

<?php
// site 2 wp-config.php
$table_prefix = 'site2_';
define('CUSTOM_USER_TABLE', 'custom_users');
define('CUSTOM_USER_META_TABLE', 'custom_usermeta');

this will effectively isolate the content of each site, but allow them to share the same userbase. It also means editing a user one one site would change that user on the other site, of course.

WooCommerce uses custom post types as containers for their orders, subscriptions, etc. so you’re not going to be able to “share” them between two sites easily at the application level. You could use something like MySQL triggers to auto update from one sites orders to the other, but that seems really brittle.

Leave a Comment

error code: 523