As promised at Wordcamp Toronto 2009, I’m pleased to annouce the launch of b5media Labs! Moving forward, this will serve as our test bed for new ideas and technology demonstrations and as our resource to talk about some of the stuff we’re doing or have done with all of you!
Also as promised, in this first post I will re-outline my Wordcamp presentation on integrating Wordpress MU, bbPress and buddyPress and go into a little more detail from a code perspective.
Step 1: Software
The first step is to install all of the various software components. We are using three software programs: Wordpress MU, bbPress and buddyPress. All three are from Automattic or a derivative of the Wordpress code base so fortunately for Wordpress developers, there’s already an inane level of familiarity there. So go ahead and set up all of the different software packages.
Wordpress MU is a pretty straight forward install. While there are plans to port buddyPress over to a single install of Wordpress (the two code bases are actually merging), for now we need to run Wordpress MU. Of course Wordpress MU can run just like a single Wordpress install, you just need to disable users signing up for their own blogs.
buddyPress will get installed info the plugins directory and requires setting up a few extra directories, but is also relatively straight forward (don’t forget to read the readme.txt file).
Finally, install bbPress into a subdirectory (ie. yourblog.com/community) under your Wordpress install.
When installing bbPress, be sure to configure it to share usernames between Wordpress and bbPress. They’ve made this a surprisingly easy part of the installation.
Step 2: Customization
Fortunately for those who have Wordpress experience, the buddyPress and bbPress templating system should be nothing new. Even if you have no experience with templating these systems, if you have PHP experience, it should be realtively easy to get up and running.
There isn’t too much to talk about under this category, but I would love to point to a couple of important things to note:
If you’re wrapping your buddyPress install in the same header/footer as your Wordpress install, you’ll need to copy all of the dependencies over into buddyPress’s theme directory (CSS, images, etc.) This is because buddyPress overwrites the return values of the theme directory functions. So while it uses the exact same functions, it reroutes all theme specific file to wp-content/bp-themes.
For bbPress, if you want to use the same header/footer files, you can just copy the header.php and footer.php into your bb-templates/[theme] directory. However, you’ll need to import the Wordpress functions into bbPress. So you’ll need to add the following lines to your bb-config.php file. Note: Do not attempt to make this fix before bbPress is installed. It doesn’t like it.
After the line “define(’BB_LANG’, ”);” include the following code (pun intended):
// Include Wordpress functionality $currDir = dirname(getcwd());
// Make sure this isn't install or admin (go up if it is)
if(!file_exists("$currDir/wp-blog-header.php"))
$currDir = dirname($currDir);
if(!file_exists("$currDir/wp-blog-header.php"))
die("Cannot find Wordpress integration files.");
require_once("$currDir/wp-blog-header.php");
This ensures that the Wordpress functions are available to you inside bbPress. bbPress works surprisingly well with this (in terms of lack of function names colliding, etc.).
That’s pretty much it for theming. So much for the good and the bad… you know what comes next.
Step 3: Integration (The Ugly)
This is ugly mostly because there are so many points where we can integrate these three solutions together. In this overview, we’ll go through including the “buddy bar” in bbPress and linking to buddyPress user profiles to replace bbPress’s rather lacking user profiles.
The “Buddy Bar”
Getting the buddyPress admin bar which shows up in Wordpress to show up in bbPress can be tricky. This usually comes in two parts. First, including the code above for customization. This will include all of the Wordpress hooks, filters, and most importantly plug-ins. Second, we need to make some theme changes. First, go into wp-content/buddypress/bp-core/bp-core-admibar.php and at the bottom, you’ll find a hook for wp_footer. We’re going to replace that line with the following:
add_action( 'bp_footer', 'bp_core_admin_bar', 8 );
As you can see, we’re replacing wp_footer with bp_footer, giving it it’s own action. Now, in your footer.php file in your Wordpress theme, where it currently calls do_action(’wp_footer’), you’ll need to add the following line after it:
do_action('bp_footer');
Now that that’s all done, it’s a simple matter of adding that same line to the bottom of your footer.php in your bbPress template. Simply find the line which calls do_action(’bb_foot’); and add the following line below it:
do_action('bp_footer');
You should now have the buddyPress bar in your bbPress installation!
Profile Linking
Profile linking is troublesome. There are two cases to consider: 1) You’re viewing a user’s profile and 2) You’re administering a user profile. This is easiest to do in a plug-in, and I have created one which you can download here. You can unzip the file inside into your bb-plugins directory and activate it from you bb-admin panel. Allow me to explain the code.
add_filter('get_user_profile_link', 'bppro_user_profile_link', 10, 2);
/* FUNCTIONS */
function bppro_user_profile_link($link, $uid) {
if(BB_IS_ADMIN || (isset($_GET['tab']) && ($_GET['tab'] == 'edit')))
return($link);
$user = bb_get_user($uid);
return(get_option('siteurl').'/members/'.$user->user_login);
}
As you can see, we’re simply replacing the link to their profile page with a link to their buddyPress member’s page, but only in specific cases. Note: if you changed the buddyPress member slug to something else, you’ll need to reflect that change here.
Step 4: Continue
Hopefully these code snippets and examples of what we’ve done have inspired you to think of new and creative ways to integrate these platforms into your own site. Every site can and should leverage these easy to use and learn programs to expand on the defaults given by Wordpress. buddyPress delivers full profiles as opposed to Wordpress’s Name/E-mail/Comment paradigm. bbPress also helps to break away from Wordpress’s typical Author -> Commentor relationship, allowing user contributed conversations and discussions to branch off in any direction.
Together the combination of these solutions is sure to build on top of any site’s popularity and usefulness.

May 24th, 2009 at 8:28 PM
This is a test.
June 6th, 2009 at 7:48 PM
And this is a test too. I see the name Terry Smith now. Trying to find the bbPress/WPMU/BuddyPress integration info mentioned by @jeremywright at #wcchicago. And, hope I will be able to follow new comments here.
June 6th, 2009 at 8:25 PM
Hi Chris; thanks for dropping by! I should have the rest of the article completed early this week. I look forward to your feedback.
June 7th, 2009 at 7:04 AM
This is a good news!
i’ve fully integrated mu+bp+bbpress but my only problem is show the buddybar on forums page… like your project splendicity.
i’m waiting the start of project!
July 27th, 2009 at 4:50 PM
Great work Terry!
July 27th, 2009 at 4:58 PM
This kind of integration is powerful. I’ve several sites that I’d actually like do deploy a similar solution on. The first one will be the our church’s website I think…
July 28th, 2009 at 4:25 AM
Thanks for the article.
I just have one query, the integration I am working on is using a subdomain for the forum, so including wp-blog-header.php is forcing the forum to redirect to the blog URL.
Any idea of a quick fix to this without having to hack core files?
Thanks
July 28th, 2009 at 5:41 AM
Think I’ve answered my own question. I created a blog in the site admin with the name forums.domain.com which I set as non public.
I then edited the siteurl option for that blog to be the main install siteurl, this allows the forums to be shown as MU thinks it is a valid blog and allows your plugin to work linking to the BP profiles.
forums, and forum are also set up in my banned names.
Andrew
July 28th, 2009 at 4:51 PM
Hi there,
Does this guide still apply to BP/WPMU/bbP versions 1.0.3/2.8.1/1.0.1 ? Not to mention that bbP 1.0.2 is out…
July 28th, 2009 at 5:49 PM
Congrats Andrew; good call. We have similarily created a page in wordpress that point to the community directory for bbPress on our sites.
el_terko, we are running 1.0 versions of bbPress and buddyPress, though this will work with 0.9 versions of bbPress and RC versions of buddyPress as well. Backwards compatibility with Wordpress is usually almost guaranteed since they work hard to ensure it is there, but yes, I can confirm this works with 2.7 through 2.8.1.
July 28th, 2009 at 11:39 PM
[...] finicky. Terry put up a post on our experiences tieing it all together for our b5media sites at: http://labs.b5media.com/blog/creatin…ress-solution/ Hopefully this is helpful! Joe Taiabjee work: b5media.com - blog: joetek.ca - twitter: [...]
August 4th, 2009 at 6:42 PM
Great stuff Terry. Another question that has been bugging me: What about the registration process? Is there any good way to send people from bbpress to the buddypress registration and then back to the bbpress home again?
August 4th, 2009 at 10:24 PM
Great question Simon! In our install, I have modified our theme’s register.php and login.php to redirect to Wordpress’s system. Here are the contents of those files:
register.php:
header(”Location: ../wp-signup.php”);
login.php:
if(isset($_GET['re']))
$re = $_GET['re'];
else
$re = $_SERVER['HTTP_REFERER'];
wp_redirect(get_option(’siteurl’) . ‘/wp-login.php?redirect_to=’ . urlencode($re));
As you can see on the login, I do my best to redirect the user back to where they started.
Hope this helps!
August 6th, 2009 at 4:42 PM
nice job! keep cruising