Multiple BuddyPress Social Networks

Since the merge of WordPress and WordPress MU, WordPress has supported running multiple WP networks in the same WP install. This site has been part of a multi-network install for more than two years. In WordPress, the networks are almost completely separated so we can create an infinite amount of blogs similar to Blogger, Tumblr, and other social media networks. The only thing that is shared between networks is the user information. Since BuddyPress is primarily focused on the users, when it is active in multiple networks in the same WP install, the BP social network is common across networks.

Over the last year plus, I’ve been collaborating with the BP core development team to add the ability to have multiple separate BuddyPress social networks in the same WordPress install. Over the last week, a number of changes have been rolled into BP trunk to support separate networks. However, by default, BP will continue to function as a single network across WP networks consistent with the current behavior. A plugin is required to enable multiple distinct BP networks.

Note: check out these BuddyPress examples to see what you can create. You might want to add a forum to your site via bbPress

You also need to have a plugin to create multiple WP networks in your install. For that, you can use either WP Multi Network or Networks+.

You can download an alpha version of my BP multi-network plugin below. This is currently only for testing and should be used on a test site. Once BP 1.3 is released I’ll be adding this to the plugin repository at wordpress.org. Instructions for using this are:

  • install the latest version of BuddyPress trunk http://buddypress.trac.wordpress.org/browser/trunk. You need at least revision #4392.
  • install bp-multi-network.php in the mu-plugins folder (must be installed there to work correctly)
  • create your second WP network with one of the plugins above
  • activate BP on the sub network and go through the installation wizard
  • for forums you need to tweak your bb-config.php a bit – see below

Download the plugin here.

bb-config.php changes

Your bb-config.php has a line similar to

$bb_table_prefix = 'wp_bb_';

Change that line to

if( function_exists( 'bp_core_get_table_prefix' ) )
	$bb_table_prefix = bp_core_get_table_prefix() . 'bb_';
else
	$bb_table_prefix = 'wp_bb_';

A few lines below that you’ll see a line similar to

$bb->uri = "http://domain.com/wp-content/plugins/buddypress/bp-forums/bbpress/";

change that line to

if( function_exists( 'get_current_site' ) ) {
	$current_site = get_current_site();
	$bb->wordpress_mu_primary_blog_id = $current_site->blog_id;
	$bb->uri = BP_PLUGIN_URL . '/buddypress/bp-forums/bbpress/';
} else
	$bb->uri = "http://domain.com/wp-content/plugins/buddypress/bp-forums/bbpress/";

46 Comments

  1. Ron – this is awesome. Think i pee’d a little when i read the title.

    Kidding aside, in theory if you have multiple BP networks, the next logical step would be to gather data/content from these networks on your main site/blog (similar to the demand of having blog posts from multisite networks on the homepage). Not to jump ahead too much, but I assume this might be a topic that will be explored down the eventual line? Any general thoughts or hints to get one started on investigating this.

    Otherwise I look forward to throwing this on my local dev in the next day or so.

    • You would have to do something similar to what Sitewide Tags does. I’d be inclined to wait until BP is migrated over to custom post types. CPTs would substantially reduce the amount of dev involved.

      • Good point. Do you happen to know where CPTs are on the BP roadmap?

      • Yes, please develop the ability of mother-networks to show what’s happening in the child-networks!

        There are thousands of physical communities, like the towns of Lake County, Oregon, that would love to have their own child-networks under a mother-network. In our case, the mother-network would be Lake County and the child-networks would be each of our towns.

        I am currently researching the feasibility of creating community websites for our towns. I believe that the most successful format would be that of a social network. Assuming you could give us the technical support we would need to implement the network, we would love to be your guinea pig. Let me know!

        • “Yes, please develop the ability of mother-networks to show what’s happening in the child-networks!”

          That’s the way BP works out of the box. The point of this plugin is to segregate the BP content into separate networks.

  2. Hi Ron,

    Will the user profile and activity being synced across the different BP sites under Multi BP Networks.

    Hope the new BP will be release soon.

  3. Awesome! Awesome!

    I currently run three different BP installations because I needed to create 3 different BP communities on the same domain. We didn’t want the activity, groups, and forums showing up in the other communities, but we wanted to share the same user db (It was way too wonky to get them running off of one user DB, and so I decided to play it safe and created three different installs.) Plus, we want our groups to eventually to be able to create their own blogs. Migrating will be a nightmare because a select few are members of two or all of the communities, but for plugin management, I think it would be worth it!

    • We pretty much need the same thing (I think)…

      We want to have the main network (www.SocialPlanet.org) be the master db, where everyone is a member of SocialPlanet. But we also have sub-communities that want to have their own members and content.

      For example, a hierarchy might look similar to this:
      SocialPlanet.org (members – 1,2,3,4,5)
      – SocialPlanet.org/subnet1 (members 1,5)
      – SocialPlanet.org/subnet2 (members 2,3)
      – SocialPlanet.org/subnet3 (members 2,4,5)

      Maybe I’m on the wrong track here, but this would be perfect for us.

      We are currently trying to use the Groups feature under the SocialGo platform as our sub-networks (communities) but it’s just not working out for us.

      If anyone would like to see what I am talking about just visit http://www.SocialPlanet.org

      We desperately need a solution for this. We have multiple non-profit organizations that are interested in becoming part of the Social Planet network, but they need their own space where they can focus on members that are interested in their mission.

      Any input or direction on how to move this forward would be GREATLY appreciated!

      • Have you tried the plugin in the post?

        • (blush) no. I haven’t tried the plugin yet.

          I am soooo new to WP. BUT, I am just starting to get my head around it.

          I have a multisite installation up and running with BP installed. But in truth, I am still trying to understand how it all works. Different themes, BP, etc.

          Anyway, I will try to install the plugin and see what happens.

          Also, I just want to say thanks in advance Andrea. I have seen your posts on various sites over the last few months that I’ve been reading about WP and I really value your input.

          • Well, I guess this is beyond me.

            I installed the plugin, but for the life of me, I cannot find the “mu-plugins” folder that it is supposed to install to. It got installed to the “plugins” folder under the “wp-content” folder.

            Is it my old age that’s causing me to feel completely lost or does WP take a little getting used to? LOL

            Aaaaaaanyway, I installed it as the network admin thinking that was the best thing to do, but in truth, I’m completely lost.

            Maybe when things mature a bit and there is some documentation for idiots like me, I can figure this out, but for now I feel like a complete retard.

          • You have to create the mu-plugins folder if it doesn’t exist. See https://wpmututorials.com/basics/what-is-the-mu-plugins-folder/. It will not work properly if it’s installed in the plugins folder.

            Also, the plugin above is for BP 1.3 (currently in development) not BP 1.2.8. You have to download 1.3 either via SVN or tract (http://buddypress.trac.wordpress.org).

          • Awesome,

            Apologies for being such a newbie with WP/BP and tackling cutting edge stuff like this. But I have been starting companies over the last 25 years in Silicon Valley haven’t kept up with the tech side of things over the last 10 years or so.

            That having been said, I have been able to take a couple of companies public and have a few start-ups go through acquisition. So the fact that I know exactly what I need in terms of product features, and there is nothing really out there yet to suffice, is pretty much par for the course. 😉

            Maybe we can use your professional services once we get a good track on which direction we are heading?

            Anyway, Thanks Ron!

  4. […] options table of BP_ROOT_BLOG. But in non-standard setups – including BP_ENABLE_MULTIBLOG, or multinetwork BP – certain options may need to be stored somewhere other than BP_ROOT_BLOG. The bp_x_option() […]

  5. Hello Andrea and Ron,

    I tried to install everything in the way you described, after setting up a running network, with BP 1.3-bleeding and the WP Multi Network Plugin. It seems not to work as excepted. The bp-multi-network.php does it’s update feature well, but the following point is not possible:
    – activate BP on the sub network and go through the installation wizard
    because BP is not available on the sub network, I can only activate it in network admin mode.
    Activated by this way it works as traditional BP. The group directory etc. not showing up, because these sites are missing, but in the BP admin bar navigation all directories are available – pointing on the main site (mother network).

    I’m not sure if I used the WP Multi Network options correctly, there is no documentation available. Tried to play with the clone options but I don’t come along well.

    Sure I’m thinking of buying your Network Plus plugin – if this will solve the problem! Do you think the WP Multi Network doesn’t do the job well, did you test it? Or am I expecting too much for now?

    By the way, when installing further more BP plugins now it gives me an error message that I first have to install BP. But BP surely is installed and active.

    Thanks for your development, it’s exactly what I’m looking for,
    Fée

    • I’m the author of Networks+ and I used it to create the multi network install that I used to develop & test the BP multi-network plugin.

  6. Hi Ron,

    tried use BP Multi-Network and it was working in the test site. But would like to know if it will work with BP 1.5 when released.

    Thank you,

    • BP version 1.3 (per the post above) was renumbered to BP 1.5. The above plugin was written for BP 1.5.

      If you are saying you tested it with BP 1.2.9 and it worked, your testing wasn’t very thorough as it does not work with 1.2.X. The BP filters it uses don’t exist in 1.2.X so it doesn’t do anything in 1.2.X.

      • Hi Ron,

        Thanks for the reply.

        I have WP 3.2.1 and BP 1.5 beta 1, and Networks+ plugin plus this BP Multi-Network plugin (these 2 plugins are in mu-plugins folder).

        The BP in the new network was not working as I will be directed to the main network’s BP site.

        I just removed everything from the test site and will wait for your instructions to start a brand new test.

        Hope it will work. Really like this plugin!

        • I won’t have a chance to look at this probably before the first of next month.

          However, at the time I was working on this the second network was not redirecting to the main one. If that redirection is a result of a change in BP, I won’t be fixing that in this plugin.

          Networks+ already has code in it for the second network to make the BP root blog the second network’s main site. See what happens on the second network when you remove the bp-multi-network plugin.

          • Hi Ron,

            Thanks for the reply.

            I had done 2 more tests and here are some of the results.

            I setup 2 WP installs, first one http://www.example.com (WP 3.2.1, BP 1.2.9, Networks+, BP Multi-Network)
            , and the second one is demo.example.com (WP 3.2.1, BP 1.5 beta 2, Networks+, BP Multi-Network)

            Both WP installs have BP activated on secondary blogs (2nd site of the Main Networks by adding “define( ‘BP_ROOT_BLOG’, 2 );” to the root wp-config.php ), and in Second Networks, BP are also activated.

            But both WP installs’ Second Networks BP still linked back to the Main Networks’ BP sites.

            So I added “define( ‘BP_ENABLE_MULTIBLOG’, true );” to both WP installs’ wp-config.php.

            And the result were that the Second Network’s BP site in demo.example.com (using BP 1.5 Beta2) is still linking back to Main Network’s BP site. And strangely, the Second Network’s BP site in http://www.example.com (using BP 1.2.9) Worked! it became a totally separate BP network with its own groups, forums activity and so on.)

            I was not sure if BP Multi-Network did anything to http://www.example.com‘s BP sites or it was mainly the line I added to wp-config.php ( “define( ‘BP_ENABLE_MULTIBLOG’, true );” )that did the trick as you mentioned BP Multi-Network will not work under BP 1.2.9.

            So above are my findings after several installs over the past days, and hope you would give me some instructions or maybe direct me to the right direction.

            Thank you very much,

          • (2nd site of the Main Networks by adding “define( ‘BP_ROOT_BLOG’, 2 );” to the root wp-config.php )

            That’s your problem. You’ll have to write a mu-plugins plugin to define that value for each network. You’re forcing the second network to use blog 2 as the BP home site. Give the plugin a name like aaa-something.php.

      • Hi,

        Thanks for your work, this is really great stuff.

        I had got the impression from reading various forums and from talks at WordCamp that this functionality:

        “A multisite network of BuddyPress sites, each with their own users, feeds etc. ”

        is going to happen natively with the final release of BP 1.5

        Do you have any more information on this? If your plugin getting rolled into core or will it become obsolete?

        Thanks in advance,

        Simon

        • is going to happen natively with the final release of BP 1.5

          That’s not true. You need the plugin above to have segregated networks.

          Also be aware that in WP (and BP) there is only one set of users across the entire install.

          • I was mainly referring to this:

            http://2011.sf.wordcamp.org/session/whats-new-in-buddypress-1-5/

            At 14:10 James Jacoby answers a question asking about having a network of BP site – a kind of ‘BPMU’

            Am I missing something here or is this the same functionality that your plugin delivers?

            Thanks in advance,

            Simon

          • Per the post above

            However, by default, BP will continue to function as a single network across WP networks consistent with the current behavior. A plugin is required to enable multiple distinct BP networks.

  7. Hi Ron

    I commented out the line “define( ‘BP_ROOT_BLOG’, 2 );” and everything is working as designed.

    As per your reply, now the only site in the Main Network that can use BP is the root site, right? So I need a plugin as you suggested to make that happen. As I am not a programmer so I guess I will have to wait for the plugin to be created by a developer.

    Thank you again for the reply and instructions.

    • The plugin is in the post above. That;s what the post is about and there’s a download link that I moved to a more prominent and obvious location.

  8. Hi
    I’m quite interested in your plugin but am having trouble getting it to work. I think I followed your instructions.

    I installed Networks+ on existing WordPress 3.2.1 installation and successfully set up two new network sites.
    I upgraded my existing BuddyPress to rev. 5153. (BP 1.5 rc1) It is network activated.
    I installed bp-multi-network.php to the mu-plugins folder.
    I didn’t make any changes to bb-config.php yet.

    I don’t see any way to activate BP on the sub-networks. There is no option in the Plugins tab and not anywhere else. If I click in Network Admin from the sub network it takes me back to the parent network (but only if I’ve deleted cookies).

    Can you give me ideas on what to check that I might have done wrong.

    Thanks

  9. Hi,
    I had created the multi social networking sites using buddypress. Each site is having some users. same users can be in both the sites. When i am seeing the members directory for all the networking sites in the web page, shows a list of all the users in all the networking site and not displaying the users particular to a networking site.
    please help me.

    Thanks in advance.

    • From the first paragraph of the post above:

      In WordPress, the networks are almost completely separated. The only thing that is shared between networks is the user infomation.

  10. This all works fine but for one problem (that seems to be purely aesthetic but rather disruptive on the page). On the dashboard for the wordpress subnetwork with buddypress activated, and on the actual pages themselves, I get the following error:

    Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/avatars/1) is not within the allowed path(s): (/f5/mysite/:/nfsn/apps/php53/lib/php/:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/) in /f5/mysite/public/wp-content/plugins/buddypress/bp-core/bp-core-avatars.php on line 195

    So again, this is displayed on the dashboard and on the pages (anywhere where there is an avatar).

    I can’t for the life of me figure out how to make this go away. The user avatars load fine, so I don’t know why there is an error anyway. I deactivated an uninstalled buddypress and re-installed/activated it again, but the problem persists.

    Any help would be greatly appreciated. Thanks very much.

  11. Thank you so much for this post. It helps me a lot in making my network’s buddypress to a have separated activities, etc.

    I like the way users are maintained, but their AVATARS where extremely gone!

    I tried uploading new avatar for myself and I’m surprised to see that it does actually accept the file/image.

    Now my problem is I dont want to have this kind of behaviour, I want all my user to have one avatar in all the networks I have. Please help :). Thank you so much!

    • You’ll have to hire a developer to look at that. Most people just use gravatars which will be consistent across the networks.

      • Thank you so much for the reply.

        I figured it myself :).

        I created a custom plugin file and activated it in network admin with the following code:

        Tested and it works!

        Hope this will help people with the same situation as mine.

        Thanks again Ron!

        • $dir = __DIR__ . '/../uploads';

          $uri = get_bloginfo('siteurl') .'/wp-content/uploads';

          define( 'BP_AVATAR_UPLOAD_PATH', $dir );

          define( 'BP_AVATAR_URL', $uri );

Leave a Reply to joeCancel Reply