Share users across multisite but not permissions

Hi,

I'm looking for a solution to share users across several websites, I mean when you're registered on one site you're registered on all others.

I used

define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');

So I got the login/password informations shared across websites which is good.

However I got a problem with the user role as it is prefixed with db_prefix.

How can I automatically assign a default user role if the user successfully connect and as no user role?

  • Adam Czajczyk

    Hello Emmanuel,

    I hope you're well today and thank you for your question!

    The way you share users across multiple websites currently implies that there's only a single place where all the user data is stored. These two tables that you share between WordPress installs are used to keep information about user account so as a result the user-role will be the same because the user account is "physically" the same here.

    I think that this could probably be changed with some advanced "near hacking" custom code that would "dynamically" change user rule depending on the site the user is currently using but I never even considered trying this.

    I didn't came across solution like this but you could try our "User Sync" plugin instead as instead of sharing the database tables it just sync user data across completely separate WP installs. User account data is copied (mirrored) to other site(s) rather than being "shared". It does replicate user-role as well but it could be then possible to manually change roles of users or use some additional custom code to automatically change them "in bulk".

    The best solution here though would be moving to a WordPress Multisite in my opinion. With a "Multisite User Management" plugin you would be able to achieve that as it would automatically add users of one (sub)site of the network to other sites and would let you set default roles for each of the sites.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.