I have a WordPress Multisite installed (single domain + subfolders - each instance for a different country - so multiple languages but for now single currency - euro)

Users are automatically added to all instances (using "Join my site") - so you can use your login on all instances.

Now the problem is:

We want to launch a premium subscription-based membership (which would then active discounts).

When a user purchase a subscription on one site, he is granted a membership plan. Now the question is, how can I automatically activate it on all instances?

I was thinking to run some code when it's purchased that gift it to the same user on all other instances.

But maybe there is a plugin for that? Or something similar that I could use as base to build on?

Or some API doc that could be useful? I am bit clueless how to start here.


I have partially fixed the problem by writing a plugin where I generate a shortcode that I can use to progammatically after membership if user is logged in.

function wp_add_missing_membership ( $user_id, $plan_id ) {
    if ( ! function_exists( 'wc_memberships' ) ) {
    $args = array(
    // Enter the ID (post ID) of the plan to grant at registration
    'plan_id'       => $plan_id,
    'user_id'       => $user_id,
wc_memberships_create_user_membership( $args );

// Get the new membership
$user_membership = wc_memberships_get_user_membership( $user_id, $args['plan_id'] );

// Add a note so we know how this was registered.
$user_membership->add_note( 'Membership imported from other site' );

function has_woocommerce_subscription($the_user_id, $the_product_id, $the_status) {
    $current_user = wp_get_current_user();
    if (empty($the_user_id)) {
            $the_user_id = $current_user->ID;
    if (WC_Subscriptions_Manager::user_has_subscription( $the_user_id, $the_product_id, $the_status)) {
            return true;

function bb_fixmembership ( $atts){
    $a = shortcode_atts( array('plan' => '0'), $atts );

    $what_s_the_plan = $a['plan'];
    if ( is_user_logged_in() ) {
            $user_id = get_current_user_id();
            if (wc_memberships_is_user_active_member($user_id, 'student')) {
               // do nothing - all is good
            } else {
                    wp_add_missing_membership($user_id, $what_s_the_plan);


add_shortcode( 'fixmembership', 'bb_fixmembership' );

Now I need to synchronise this with subscriptions accross websites - which I might do using hooks and user metadata.

I am just posting an answer since i don't see most post being answered :) so I thought this might help somebody else...

Will post when I fix it entirely.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.