bbPress & WP Theme Integration

Update: I have written an updated article after the new releases and it can be found here.
http://www.adityanaik.com/integratepress-part-i/

I have been working on bbPress for quiet sometime now. Since most of use using both wordpress and bbPress integrated them and create similar themes, I thought I’ll add support for the bbPress forum Themes to all the wordpress themes that I create from now onwards.

Here is primer for integrating Wordpress and bbPress Themes:

bbPress Configuration

$bb->wp_table_prefix = 'wp_';

You can find this information in the wp-config.php file in the wordpress installation directory.

$bb->wp_home = 'http://www.<your_website>.com/ <your_blog_directory>';
$bb->wp_siteurl = 'http://www.<your_website>.com/ <your_wp_installation_directory>';

You can find these information in wordpress admin page. Go to Administration > Options and you will find these values under the ‘General Options’ Tab. If you are installing bbPress in a folder other that subfolder of the wordpress installation, you might run into some cookie trouble. Have a look at this and fix the cookie definitions.

define('WP_BB', true);

Set this value in the config file so the functions defined in Wordpress are not redefined.

require_once( '/path/to/wordpress/config/file/wp-config.php');

Update: Add the above statement to the config.php in bbPress. Note that this statement goes on top of the file before everything!. This will get all the functions from Wordpress into bbPress.

Plugins

You will have to install two plugins one for wordpress and one for bbpress. So that whenever a user signs up on either of the softwares it will add permissions for the other forum and the second one to manage how the name is displayed.

Download the Wordpress plugin from here and the bbPress Plugin from here

And now you are all set.

Integrating the themes is done. now you can just drop this template (Update Note: the template is outdated. You can download the latest file from here http://www.adityanaik.com/integratepress-part-i/) in my-template folder and the template is wordpress ready! All this template does is call get_header from wordpress rather that bb_get_header from bbpress. this way any change you make in wordpress template reflects in bbpress immediately.

3 Trackbacks/Pingbacks

  1. Pro Forums » bbPress & Wordpress Integration on Jan 7 '07

    [...] I saw this really wonderful how-to on bbPress & Wordpress integration written by Aditya Naik and I wanted to share it here so that hopefully some people may see it who didn’t have the chance before. It’s very helpful! Here is primer for integrating Wordpress and bbPress Themes: [...]

  2. Announcing the Imperishable Inheritance Forum! » Imperishable Inheritance on May 2 '07

    [...] for proving the fantastic software that integrates so well with WordPress! Also, I came across a great article on how to integrate the [...]

  3. SocialSync » Blog Archive » TO DO! on May 11 '08

    [...] http://www.adityanaik.com/bbpress-and-wordpress-integration/ [...]

53 Comments

  1. Jonathan

    So I believe I’ve followed all of the steps you give, but thus far cannot get the forum to work after modifying this part of the config file (below the comment that says “stop editing”):
    require_once( ‘/path/to/wordpress/config/file/wp-config.php’);

    I made the path absolute (begins with http://) because I got an error that the config file couldn’t be found otherwise (perhaps because I’m running php on a Windows box?).
    Here’s the error I get now when I try to go to the main bbPress page:

    Fatal error: Call to undefined function: do_action() in d:\mysiteroot\wordpress\forum\index.php on line 6
    If I try to go to the admin page now, I get this:

    Fatal error: Call to undefined function: bb_auth() in d:\mysiteroot\wordpress\forum\bb-admin\admin.php on line 4

    I’ve activated and configured the WP plugin you link to and uploaded the bb plugin to the my-plugins directory and uploaded the my-template file you made available
    …what else am I missing here?

    Saturday, January 20, 2007 at 04:02 pm | Permalink
  2. Aditya

    the absolute path is always the system path not the url.. so your absolute path will be ‘d:/mysiteroot/wordpress/wp-config.php’

    try this and let me know if it works..

    Saturday, January 20, 2007 at 07:27 pm | Permalink
  3. Jonathan

    That moved me past the first error when I try to go to my new forum home page, but now I get a new error, as i it can read the WP functions, but not the bb functions:

    Fatal error: Call to undefined function: get_forums() in d:\mysiteroot\wordpress\forum\index.php on line 11

    Do I need to re-run the install in order for everything to be pulled in correctly, after I changed the config file?

    thanks for the help!

    Sunday, January 21, 2007 at 09:15 pm | Permalink
  4. Rob L.

    I’ve followed all the steps here but I still just get the basic, default bbpress theme, not my Wordpress theme. I have no errors or anything, but nothing has changed. Would the Wordpress K2 theme create a problem?

    Sunday, January 21, 2007 at 10:29 pm | Permalink
  5. Jonathan

    I’ve continued to fiddle with the config.php and just cannot get it to work — the error “Call to undefined function: get_forums()” seems to be the most recurrent error. I can get other to appear by doing different things to the config file, but that just seems to be regressing based on those errors. Any other help would be much appreciated.

    Sunday, January 28, 2007 at 11:51 pm | Permalink
  6. Aditya

    can you tell me what changes you have made and what is the content of the config.php exactly

    Monday, January 29, 2007 at 03:21 pm | Permalink
  7. Jonathan

    I have these settings configured correctly:
    $bb->wp_table_prefix = ”;
    $bb->wp_home = ”;
    $bb->wp_siteurl = ”;

    If I use only these additional two settings, the forum will work by itself:
    define(’BBPATH’, dirname(__FILE__) . ‘/’ );
    require_once( BBPATH . ‘bb-settings.php’ );

    That doesn’t do the integration, though, with WP, so I tried adding in these settings:
    define(’WP_BB’, true);
    require_once( ‘d:\mysiteroot\wordpress\wp-config.php’ );

    I’ve tried using either one or both of those; I’ve also tried using those and taking out
    define(’BBPATH’, dirname(__FILE__) . ‘/’ );
    require_once( BBPATH . ‘bb-settings.php’ );
    …but that doesn’t work either.

    Wednesday, January 31, 2007 at 12:22 pm | Permalink
  8. Aditya

    you need to have all four statements

    these:
    $bb->wp_table_prefix = ‘’;
    $bb->wp_home = ‘’;
    $bb->wp_siteurl = ‘’;
    I assume you have filled in values..

    these:
    define(’WP_BB’, true);
    require_once( ‘d:\mysiteroot\wordpress\wp-config.php’ );
    need to go on the top of the config.php file before everything else..

    Wednesday, January 31, 2007 at 01:40 pm | Permalink
  9. Jonathan

    Adding those two config settings to the *top* of the config.php file fixed it — now it works great! Thank you!

    Wednesday, January 31, 2007 at 10:49 pm | Permalink
  10. Aditya

    glad it worked for you!

    cheers!

    Wednesday, January 31, 2007 at 10:57 pm | Permalink
  11. david

    Your article is very informative and helped me further.

    Thanks, David http://www.google.com

    Sunday, February 4, 2007 at 07:38 pm | Permalink
  12. Aditya

    Thanks David.. I’m glad to help!

    Sunday, February 4, 2007 at 09:01 pm | Permalink
  13. andyh2

    Hi. I’m trying to get the template thing working with the newest stable version of bbpress and it doesn’t work. I downloaded the “my-templates” folder and it doesnt have a header.php or footer.php. Is it for an old version of bbpress?

    Thursday, February 8, 2007 at 10:58 am | Permalink
  14. Aditya

    yup.

    1. it works with the old release.
    2. it does not have a header and footer because it takes the header and footer from the wordpress theme.

    I’ll have to release the file with updated stuff for the latest release. thanks for the heads up.

    if you would like to it yourself. all my tempalte does is replaces the bb_get_header() with get_header() in all the template files..

    Thursday, February 8, 2007 at 11:07 am | Permalink
  15. Pete

    A simple solution for the latest bbpress: follow the steps above except installing the template. Instead, replace the contents of the default template header.php with and the contents of footer.php with

    Thursday, February 8, 2007 at 08:02 pm | Permalink
  16. Bo Bang

    Hi,
    Thanks for this information. I’m trying to integrate bbpress into my current theme, but I’m stuck. Registration part is done, but in which file do I put that last (require) code?

    Thanks in advance

    Friday, February 9, 2007 at 07:07 am | Permalink
  17. Aditya

    the require statement goes in the config.php at the top of the file. may be i should up date the article :)

    Friday, February 9, 2007 at 11:31 am | Permalink
  18. Shannon

    Hi. I’ve tried to get this working with wordpress 2.1 and the newest version of bbpress. Everything appeared fine except that wordpress states that my admin user doesn’t have the correct rights to access wordpress after bbpress is installed.

    Do you know why wordpress won’t allow the admin to log in after bbpress is installed (separate folder ‘forums’)?

    Thanks.

    Thursday, February 15, 2007 at 11:58 pm | Permalink
  19. Aditya

    Intuitively, I don’t know what could be wrong. check for following things.

    did you put the plugin for bbpress in the right place and wordpress plugin is activated.

    second can you log into bbpress if yes. may be its a cookie thing.

    I could help you debug. let me know.

    Friday, February 16, 2007 at 09:22 am | Permalink
  20. Naif Amoodi

    Hi Aditya. How are you doing? I have been trying to integrate WP with BBpress using this guide from the past 4 hours or so and all my attempts have gone in vain. First of all, I would like to know if I need to use the same database for WP and BBPress? At first both were using two different databases and I was getting an error which stated that the script couldnt find table wp_users in the database. So I thought I need to use the same DB for both the installations. I did that. Everything seems to work but I am not able to access the BBPress admin panel. And I assume the line define(’WP_BB’, true); needs to be added in the config file of BBPress, am I right?

    Please get back to me soon. Thanks

    – Naif

    Monday, February 19, 2007 at 06:59 pm | Permalink
  21. Aditya

    First of all, I would like to know if I need to use the same database for WP and BBPress?

    Yup both have to be in the same db.

    And I assume the line define(’WP_BB’, true); needs to be added in the config file of BBPress, am I right?

    Yes. and this needs to be place before the line which says – /* Stop editing */

    you said you couldnt access the admin panel. firstly make sure you have the installation for wordpress up and running before you go and install the bbpress.

    let me know if you need help.

    Monday, February 19, 2007 at 08:35 pm | Permalink
  22. Erik

    Hi,

    Thanks for the help so far, its helped me a lot so far.

    But I seem to be stuck at this point:

    http://www.dodge-srt8.com/forum/

    I can get most of the header and the footer (though it is positioned wrong) but all the forum layout gets messed up and has no styling.

    Any suggestion would be very helpul. Thanks

    -Erik

    Wednesday, March 7, 2007 at 12:34 pm | Permalink
  23. Aditya

    I can see the frontpage but the links don’t work because of the rewrite mod. check the documentation for pretty URLS. you will have to add multiviews to htaccess.

    Wednesday, March 7, 2007 at 12:56 pm | Permalink
  24. daddo

    Hi,

    Followed your instructions, and the ones on the bbpress.org, everything seems to be working, except for the my-theme, this of coarse is because of the sub.domain.com route, how would I go about this to achieve the same result, because this what you did is amazingly simple solution for a headache problem ;)
    Thanx, Daddo

    Thursday, April 5, 2007 at 05:29 am | Permalink
  25. Aditya

    There are a couple of things you can do to your site.

    I saw that you tried the permalinks. you wil have to change the .htaccess file to ass multiviews option. have a look at this

    If the problem is with the cookies check this out.

    i didnt really understand your my-theme problem.. can you tell me more about the problem?

    Thursday, April 5, 2007 at 08:48 am | Permalink
  26. daddo

    Hi,
    Thank you for the permalink tip it worked!
    As for the my-template it could have been that I’ve misunderstood, but I got the impression that the template file you offered for download would integrate my WordPress theme with bbPress one, if it is supposed to do this, it’s not happening at my forum, or is it that I have to add the css style that will simulate my WP theme design, and how about the wp header could you elaborate.
    This is not clear to me and is certainly due to my inexperience with such issues, if you can see through this where did I go wrong, please advise!
    Thank you !!!

    Thursday, April 5, 2007 at 10:16 am | Permalink
  27. Aditya

    it should automatically.

    i need to know a couple of things:
    - which ver of bbpress are you using?
    - have you activated the theme in the theme admin?
    - have you dropped the files in a sub dir of the my-template dir?

    Thursday, April 5, 2007 at 11:00 am | Permalink
  28. daddo

    1. bbPress v.0.8.1
    2. do not see it in the admin
    3. dropped filez in my-templates folder
    actually dropped it as I downloaded it, since it was in the folder named my-templates and I didn’t had one.

    Thursday, April 5, 2007 at 11:05 am | Permalink
  29. Aditya

    with some changes that have been added to 0.8 you will have to move the files to a sub folder in my-templates. call it newtheme or something.

    then activate the theme. to do that go to admin and to the presentation tab. for more info see this and this

    Thursday, April 5, 2007 at 11:09 am | Permalink
  30. daddo

    Yes ! that worked,
    However now this appears ;
    Fatal error: Call to undefined function get_header() in /forum.driftkikker.com/my-templates/dK/topic.php on line 1
    As I saw, line one calls for the wp_header, and I’m in a sub.domain.com, is there something I should adjust?

    Thursday, April 5, 2007 at 11:18 am | Permalink
  31. Aditya

    make sure that you have the following in the config.php

    define('WP_BB', true);
    require_once( '/path/to/wordpress/config/file/wp-config.php');

    replace ‘/path/to/wordpress/config/file/’ with the absolute path to wordpress. also make sure this is at the top of the config.php

    Thursday, April 5, 2007 at 11:21 am | Permalink
  32. daddo

    Now I’m not sure what am I supposed to see,
    Did what you suggested, had a few routing errors, corrected it got another few, last one was with Tag Warrior, disabled it, and now all is back to default, care to have a look at forum.driftkikker.com

    Thursday, April 5, 2007 at 11:32 am | Permalink
  33. daddo

    forgot about the wp_cash it stalled the refresh a bit, it works now, I do get in topics ;
    This topic is
    Fatal error: Call to undefined function topic_resolved() in /mydomain/my-templates/dK/topic.php on line 14

    Thursday, April 5, 2007 at 11:35 am | Permalink
  34. Aditya

    ok.. the problem is that template i have have provided will use wordpress header and wordpress footer. other than that it will not style the forum at all!

    you will have to style the forum to your needs. i see this page
    http://forum.driftkikker.com/forum/1
    and looks like you have the header and footer from the wordpress. you will need to add styling for the forum to fix the garbage.

    also please check if you have replaced frontpage.php in the template folder.

    for the topic.php.. that particular function was removed from bbpress from version 0.8. what you can do to fix this is just take the topic.php from default theme and change calls to bb_get_header() to get_header()

    Thursday, April 5, 2007 at 11:37 am | Permalink
  35. daddo

    Thank you ever so much Aditya,
    You are the KING !!!
    I think I can manage from here ;)

    All the best, and my sincere appreciations for your help !

    Keep up the great work!

    Many friendly greetings, Daddo

    Thursday, April 5, 2007 at 11:42 am | Permalink
  36. intellivision

    Thanks for this modification Aditya. One question:

    do you know why the forum’s index page will not take the WP header and WP footer? All the other pages of the forum do take it.

    http://foodiephotos.com/wp/forum/

    Friday, April 6, 2007 at 10:49 pm | Permalink
  37. Aditya

    duh! my bad.. i think the file was missing..

    try downloading now. it should work now

    Friday, April 6, 2007 at 10:57 pm | Permalink
  38. intellivision

    Bingo! That was it. Thanks so much for your help.

    Saturday, April 7, 2007 at 03:20 pm | Permalink
  39. Aditya

    You’re welcome

    Saturday, April 7, 2007 at 07:45 pm | Permalink
  40. Tony Lembke

    Thanks for the tips.
    I have wordpress-mu at blog.domain.com and bbpress at forum.domain.com/bbpress.
    When I add
    define(’WP_BB’, true);
    require_once( ‘/usr/home/abc/htdocs/blog/wpmu/wp-config.php’);
    to config.php in bbpress, http://forum.domain.com/bbpress redirects immediately to http://blog.domain.com.
    I must be doing something obviously wrong. Any ideas?
    bbpress 0.8.1
    wordpress-mu 1.2.1

    Tuesday, April 10, 2007 at 09:15 am | Permalink
  41. Aditya

    try this
    require_once( ‘/usr/home/abc/htdocs/blog/wpmu/wp-blog-header.php’);

    Tuesday, April 10, 2007 at 09:41 am | Permalink
  42. Tony Lembke

    Thanks.
    Unfortunately, it still redirects to the blog homepage.
    I have installed your ‘my-templates’ folder unchanged.
    The link to the bbpress plug-in in your article seems to have moved – so I have no bbpress plugins installed.
    Cheers,
    Tony

    Tuesday, April 10, 2007 at 06:10 pm | Permalink
  43. Aditya

    the plugins shouldnt be a problem. all the plugin does is share users between wp and bbpress.

    I haven’t tried the bbpress install with wpmu, have you posted this problem on the bbpress forum?

    Also the theme needs to go in a subfolder of the my-templates folder.

    Do let me know if you find a solution.

    Tuesday, April 10, 2007 at 06:28 pm | Permalink
  44. Re

    I don’t get the theme connected, but the user logins work (yay!). Followed all instructions on this page, but something’s wrong.

    You said replace frontpage file in, but that’s the first I heard that. Replace with what? Also, Presentation page does not recognize the new template — just empty box for second theme, because no style.css. So do I need to put a css file there. From the WP theme folder?

    I have “my-templates” folder in bbpress root — should it be in bb-templates instead (why have two templates folders?)?

    Sorry, I think I’m dense. Hope you can help. Thanks in advance.

    Saturday, April 28, 2007 at 02:43 am | Permalink
  45. Re

    Delete my last comment. I got it by putting a copy of default style in the folder. Now I just have to fix the middle part.

    Author Edit: I’ll keep them here for anyone else having the same problem. thanks.

    Saturday, April 28, 2007 at 03:08 am | Permalink
  46. Matt

    I followed all your steps and am able to get the header, sidebar to load. However, all the rest of the bb press styling for the other areas being displayed such as discussion, forums(all out of wack no styling). Any idea how to fix it to maintain its styling and fit within the prescribed area.

    I have a few ideas on how to fix this, but i really don’t have a clue what I’m doing;-). Would really appreciate some help and guidance.

    1. Go in and change the code on header, footer, and css file in bbpress to mimic my wordpress theme. I want to avoid having to go in and work that whole mess out.

    2. Since I am having the header, footer, and sidebar called up from wordpress, the bbpress css file isn’t successfully being called up. Is there a way to call up the bbpress CSS file? So it could load, WP Header, WP Sidebar, bbpress css formating, WP footer?

    3. While I wait I’m going to attempt to add the bbpress CSS that is being called up to the WP CSS to see if that works.

    Thanks,
    Matt

    Thursday, May 24, 2007 at 05:12 pm | Permalink
  47. Aditya

    Yup! you are absolutely right.

    I have been meaning to fix that thing since ice age. but haven’t got to it.

    here are the replies.
    1. will work but is not recommended because the next time you wish to change the theme in wordpress, bbpress will be off its rockers again.

    2. There are hooks that can do it. But it will be a while before i can write up a code for it.

    3. yes. Easy solution. Take the code for stylesheet of bbress and add it to the wordpress header.php. Everything will fall in place.

    Let us know how it goes! Cheers

    Thursday, May 24, 2007 at 05:18 pm | Permalink
  48. Matt

    Well I went with option 3. Instead of placing the CSS in the header.php I placed in in the style.css file of my theme. Having two problem:

    1. Do not know the CSS command or which attribute to add it to, to make the posts under the title, instead of occuring after the sidebar content. ex:http://mysoberlife.com/forums/topic.php?id=3&page&replies=1

    2. In internet explorer my sidebar loads in the forum area when I am logged in. I have a loop in the sidebar to show different content when a user is logged in or logged out. I messed around with the sidebar code but that made no difference. I have no idea whats going on. Any idea why it would be loading everything from livesupport down into the main forum area?

    Hope all of that made sense

    Thanks for the help!!
    -Matt

    Thursday, May 24, 2007 at 07:54 pm | Permalink
  49. dreamXG

    Excellent plugin.

    I did have trouble trying to active the new theme, but simply uploading a copy of kakumei’s screenshot.png solved the issue.

    Maybe it should come pre-packaged with a screenshot!

    Although I find it really silly, that you can’t active it without one >

    Friday, June 15, 2007 at 09:11 am | Permalink
  50. Darin

    Can I just have the template share between wordpress and bbpress … I don’t want the users of the forums to be able to login to wordpress?

    Tuesday, July 17, 2007 at 10:53 pm | Permalink
  51. Aditya

    I would think so.. just use the template and dont make changes to the bbpress config file and stuff.. that should do it.

    Wednesday, July 18, 2007 at 09:35 am | Permalink
  52. Muh'd M. Mansour

    I’m so sorry, but can anyone rewrite it all again step by step or integrate the full php codes for each modified file.

    Sunday, July 29, 2007 at 01:15 pm | Permalink
  53. Aditya

    Hey Muh’d

    I’ve been meaning to rewrite this for a long time now.. specially because there have been so many releases after this one. Will do it soon..

    Sunday, July 29, 2007 at 01:24 pm | Permalink