admin管理员组文章数量:1395291
I have a membership site (let's call it mainsite) using woocommerce memberships to protect certain pages.
I wish to create a second wordpress site (sub.mainsite) which uses the same wp user tables as the main site so signing up/logging into mainsite also registers/logs them into sub.mainsite.
This is fairly straight forward as per this article as both are on the same server /
However, I want the second site to also have woocommerce membership to protect certain pages.
Is it possible / how can I set up the second site so that this site's install of the membership plugin reads the main site's wc_membership tables (and does not create their own tables) therefore allowing memberships to be synced across both sites?
I have a membership site (let's call it mainsite) using woocommerce memberships to protect certain pages.
I wish to create a second wordpress site (sub.mainsite) which uses the same wp user tables as the main site so signing up/logging into mainsite also registers/logs them into sub.mainsite.
This is fairly straight forward as per this article as both are on the same server https://trickspanda/wordpress-share-users-login/
However, I want the second site to also have woocommerce membership to protect certain pages.
Is it possible / how can I set up the second site so that this site's install of the membership plugin reads the main site's wc_membership tables (and does not create their own tables) therefore allowing memberships to be synced across both sites?
Share Improve this question edited Mar 7, 2020 at 16:57 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Mar 7, 2020 at 15:45 sw123456sw123456 1318 bronze badges 2- Which membership plugin are you using? There is quite a good amount, at least 4 that I know of – Tofandel Commented Mar 11, 2020 at 14:06
- woocommerce/products/woocommerce-memberships – sw123456 Commented Mar 12, 2020 at 7:03
1 Answer
Reset to default 5 +50The woocommerce membership plugin uses the post table to store it's data, however pretty much all queries from the plugin will contain wc_membership
in them (they use it in all of the post_types but it may not catch all the meta_query, will need testing, see if any error or missing data happens, find all the meta keys used by the plugin in queries that don't contain wc_membership and add them to the strpos)
So there is no associated table and clear separation of data that you could use to load it correctly on the subdomain.
However, you could use the query filter to replace the prefix to lookup the correct table, you need to make sure your prefix on the subwebsite is really unique and long enough so that it won't interfere with the rest of the query (eg: 2VXOJU8Nxo_)
Then on your sub website install you would add this filter
add_filter('query', function($query) {
global $wpdb;
if (strpos($query, 'wc_membership') !== false) {
$query = str_replace($wpdb->prefix, 'main_website_prefix', $query);
}
return $query;
});
Disclaimer: this is not a very safe solution, but pretty much the only possible one with the configuration you are proposing
Another safer solution, would be that instead of having another wordpress instance for the subdomain, you use the same instance
And make or find a plugin to be able to categorize your content and display the correct content on the correct website
Like a multisite install (the memberships plugin doesn't support multisite)
You could also ask the creator of the plugin if he would be willing to add multisite support for his plugin, so that multisite installs can share the same memberships, that would solve your problem
本文标签: databaseShare users and WooCommerce memberships between two installations
版权声明:本文标题:database - Share users and WooCommerce memberships between two installations 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744679148a2619293.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论