Theoretical Multi-Server WordPress Setup with Shared Users

The organization I work for would benefit if we could take the existing WordPress installations that are located on several (~5) different servers and be able to use a universal database with the users table only. The individual servers would use a database for the remaining content.

The idea is this. Have a “main” server with all of the user’s data (some 300+ users) which whom a network admin can give/edit permissions to these users on each of the other servers.

Read More

This way, when a user logs in to one WordPress installation on one server, the user could visit another WordPress server and still be logged in with various permissions on the various servers.

This would be a 1:1 relationship for WordPress Network to Server. How would cookies or sessions need to be utilized in order to allow this?

Would an outside API login system need to be used in order to accomplish this? Or could this be done within the WordPress core files?

Related posts

Leave a Reply

1 comment

  1. It may be possible. A lot of the core API that deals with logins and cookies is pluggable.

    You could replace wp_set_current_user with something that queried your external database rather than the internal one, for instance.

    Authentication is already done via a the authenticate filter (wp_authenticate is the function that does this, and the filter is added in wp_signout).

    In short, there’s plenty of ways you could hook it, do your thing and change stuff. You would lose, however, almost all of the users API (no get_users, no user admin area, etc), except for your main site, where the user functionality resides.

    An alternative approach would be to have all ~5 servers/WP installs share the same, external database server and database. From there, set a custom user table in each wp-config.php, and each separate install with share the same user data. You’ll also need to set a different $table_prefix for each site.

    Capabilities and roles will be different on each site, due to the way WordPress stores roles/caps (they get prefixed with $table_prefix). All the core user data, namely usernames, emails and passwords, will be shared between servers.

    Of course, this is just a WP multisite install without the convenience of multisite.

    Multisite + a domain mapping plugin is probably what you want. Or you could role your own sunrise.php and skip the domain mapping plugin. It should be possible to put multiple applications servers running a WP install with a shared database server. Point all the domains at a load balancer that sends traffic to one of the application servers and you’re done.