• Is there any way using multisite and any other combination of plugins to make it so that a user only has access to see the site that they are a member of?

    In particular:
    I have a wordpress multi-site install and then installed https://buddydev.com/plugins/buddypress-multi-network/ so that I could have multiple buddypress networks.

    The problem is that I don’t want a user to be able to join any network they want.

    For example, I have 1.[domain].com and 2.[domain].com. Each one has its own buddypress network. The problem is, even if I have the private buddypress plugin installed, if someone has an account on 1.[domain].com, then they can just login on 2.[domain].com.

    I want to make it so that the user on 1.[domain].com would need to request access to 2.[domain].com in order to use it.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Untested.

    <?php
    
    /*
    Plugin Name: Block Users
    Description: Only allow members to see sites.
    */
    
    function zac_stop_users( ) {
        global $current_user, $blog_id;
    
        if( !is_user_logged_in() || !is_user_member_of_blog() && ($blog_id == 2) ) {
            // do something ...
        }
    }
    
    add_action( 'wp' , 'zac_stop_users' , 10);

    In theory this will check if someone is not logged in and not a member of the blog AND the blog is #2 (the one you want to keep private).

    Where I put // do something is where you can decide what to do. Redirect them to another page or… whatever.

    Thread Starter zacclay

    (@zacclay)

    Wow, thanks!

    I will try this out later when I get a chance. If I’m understanding this, it would block someone from a particular site if they are not a member right? What if I had hundreds of blogs and only wanted people to be able to login to the one they are a member of?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Then it’s slightly more complicated. You would have to have at least ONE site where everyone can see (I would pick your main domain, so site #1).

    Change $blog_id == 2 to $blog_id != 1 and that should do it. If they go to Site #1, everything’s fine ??

    Thread Starter zacclay

    (@zacclay)

    Perfect, thanks again!

    Thread Starter zacclay

    (@zacclay)

    sorry, one more stupid question, would I just paste that into a .php file and then upload it to the mu-plugins directory?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Yes ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Separate User Bases?’ is closed to new replies.