BuddyDev

Search

Starting afresh with BuddyPress & Multisite


  • Participant
    Level: Enlightened
    Posts: 89
    Graham Hoffman on #15203

    Hey Brajesh, hope all is well and that you can help me.

    I need to start a multisite, with the main network site just being an information based site, and it will have a membership plugin attached.

    The second site, will be my BuddyPress site.

    I’m doing this so my accounts are connected, that way I can feed a ‘verfiied’ button from the membership site to Buddypress.

    1. How does BuddyPress & Multisite share users?
    2. Is there anything specific I need to do to share wpusers on both sites (and future ones?) – especially the fact I’m using BuddyPress?
    3. How does BP get set up? Network enable? Single site only? Using the root-blog command (https://codex.buddypress.org/getting-started/installation-in-wordpress-multisite/) ?

    Many thanks for the help. I’ll be renewing my BuddyDev this weekend, I can’t believe the year had already expired!


  • Keymaster
    (BuddyDev Team)
    Posts: 11218
    Brajesh Singh on #15204

    Hi Graham,
    Welcome back. I am doing great and hope the same for you.

    1. Exactly same way as the normal WordPress/BuddyPress. The users are stored in wp_users table which is global among all sites of the network. BuddyPress simply provides(or overwrites) the way users register on the site.

    2. No. But you should know that even if the users exist globally, they may or may not have a role on a sub site. Do you want the users to be assigned certain roles on each of the site? In that case, there are some solution that can be used.

    3. It’s a good question. There are 3 choices here.

    a) BuddyPress is only active on the one sub site. All other subsite’s won’t know that BuddyPress exists. In this case, you can simply activate BuddyPress on the 2nd site.

    b) Network activated but to use 2nd site for social profiles/interactions etc:- In this case, add BP_ROOT_BLOG constant to your bp-custom.php (define(‘BP_ROOT_BLOG’, 2) ).

    c). Want to have profiles on each of the site. In this case, we call it multiblog mode.
    https://codex.buddypress.org/getting-started/customizing/bp_enable_multiblog/

    From the description, It seems to me, either A or B will be better applicable in your case.

    Thank you for being a valuable member.

    Regards
    Brajesh


  • Participant
    Level: Enlightened
    Posts: 89
    Graham Hoffman on #15209

    Thanks for the reply Brajesh,

    I’ll test a & b to see which one works best for my setup. How do you recommend providing a role on the subsites (as per your 2.) Since I’d want every user to be a subscriber to each site automatically (this is essentially single sign on, right?)


  • Keymaster
    (BuddyDev Team)
    Posts: 11218
    Brajesh Singh on #15214

    Thank you Graham.
    Please do let me know which approach suited you better.

    For adding user to blogs, you may use

    1. – to let users join a blog
    2. Or you can auto add user to the blog they visit by putting this code in a php file and putting it in mu-plugins dir

    
    
    /**
     * Plugin Name: Auto Add User to blogs
     * Version:1.0.0
     */
    /**
     * Auto add user to a blog if they don't have a role.
     */
    add_action( 'init', function () {
    
    	if ( ! is_user_logged_in() ) {
    		return;
    	}
    
    	$user_id = get_current_user_id();
    	$blog_id = get_current_blog_id();
    
    	if ( ! is_user_member_of_blog( $user_id, $blog_id ) ) {
    		add_user_to_blog( $blog_id, $user_id, get_option( 'default_role' ) );
    	}
    } );
    
    

    That will be automatically enabled across all blog and will add user to the blog they visit, if they are not a part of it. The last option is for role.

    Hope that helps.

    Regards
    Brajesh


  • Keymaster
    (BuddyDev Team)
    Posts: 11218
    Brajesh Singh on #15215

    Also,
    I forgot to post the link for option 1.
    Here we go
    https://buddydev.com/plugins/join-blog-widget/

    Regards
    Brajesh


  • Participant
    Level: Enlightened
    Posts: 89
    Graham Hoffman on #15221
    This reply has been marked as private.

  • Keymaster
    (BuddyDev Team)
    Posts: 11218
    Brajesh Singh on #15222
    This reply has been marked as private.

  • Keymaster
    (BuddyDev Team)
    Posts: 11218
    Brajesh Singh on #15223
    This reply has been marked as private.

  • Participant
    Level: Enlightened
    Posts: 89
    Graham Hoffman on #15381
    This reply has been marked as private.

  • Keymaster
    (BuddyDev Team)
    Posts: 11218
    Brajesh Singh on #15385

    Thank you. I am going to look at it now.

You must be logged in to reply to this topic.

This topic is: not resolved
Subscribe