How keep woocommerce users separeted in multisite install and keep admins on network

I'm trying to use a multisite install to keep a single php and database source but I need to use woocommerce separated in the websites, allowing the sites to have they clients separated at same time that maintain the admins in same network.

The only workarround that I found is to maintain a separated users table for each site and keep the admins in core users table than load in cache, creating a "global_users" and "local_users".

Anybody know some other way to do this or a way to improve this (maybe don't using the cache this way)?

Topic multisite-user-management woocommerce-offtopic php plugin-development Wordpress

Category Web


I don't know if is the best way to do this but aparently works well.

I override the users table adding one with an blog_id field as key. Add an "wp_pre_insert_user_data" filter to set the blog_id field and change the user id to some like "blog_id000user_id" (100044 for example is from blog 1).

Override the core "get_user_by" function to another, calling a custom "get_data_by" functions instead of the wordpress user method. This new function search the user table by blog_id and allow the admins and the site clients to connect.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.