WordPress.org

Forums

Groups
[resolved] Multisite + Groups + WooCommerce (4 posts)

  1. tctc91
    Member
    Posted 1 year ago #

    Is it possible to check from a SUBSITE within a network whether or not the current logged in user is in a specific group on the MAINSITE.

    When users purchase items in WooCommerce, I have it so that it promotes them to a 'Premium' group. However, this only occurs on the MAINSITE within my network and NOT the subsite. This is causing me problems as I must know whether they're in the 'Premium' group on all sites within my network.

    http://wordpress.org/plugins/groups/

  2. tctc91
    Member
    Posted 1 year ago #

    Solved with the following code:

    <?php

    $blog_id = 1; //set the blog id to the main site id

    switch_to_blog( $blog_id );

    $user_id = get_current_user_id();
    $group = Groups_Group::read_by_name( 'Premium' );
    if ( Groups_User_Group::read( $user_id, $group->group_id ) ) {
    echo 'PREMIUM!!';
    } else {
    echo 'Not premium';
    }

    restore_current_blog();

    ?>

  3. itthinx
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for sharing your solution :)

  4. JosiahW
    Member
    Posted 12 months ago #

    Do I need to create the group on the subsite with this code or will it automatically create the group in the subsite and assign the user to that subsite?

    Also where does this code go?

    Is there a way to sync all groups in all subsites/mainsites so that members are always in the same group no matter which site they are in?

    I would pay to have this added!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Groups
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic