bbPress

Simple, Fast, Elegant

bbPress support forums » Troubleshooting

[sticky]

WordPress + bbPress Integration 101

(75 posts)
  • Started 1 month ago by _ck_
  • Latest reply from chrishajer
  • This topic is not a support question
  1. There are way too many integration questions lately so I am going to try to gather some current info here.

    This is an unofficial help guide to try to make a fairly straightforward operation as painless as possible. Feel free to contribute and we'll edit as necessary.

    There is a "power user" shortcut below, but I am also going to try to explain more of the concepts so integration is less "magic" and easier to understand.

    With bbPress 0.9, integration is "officially" supported and there is an attempt to make it much easier to accomplish during install but it's not flawless by any means because of the wide range of possible configurations by users.

    update: for adventurous bbPress users, a 1.0 alpha is available that should integrate with WordPress 2.6 - however it is not possible to downgrade back to bbPress 0.9 (because of database changes) afterwards so please keep that in mind - also there are three new items that have to be sync'ed between WP 2.6 and bb 1.0

    Do NOT try to integrate WordPress 2.6 with bbPress 0.9 - only use WP 2.5.x - the reason for this is simple - WordPress has radically changed the way cookies are used. If you have already installed WP 2.6, don't worry you have not broken anything, you'll just need to downgrade and install 2.5 instead. 2.5.1 is perfectly stable and has no known security issues - 2.6 only adds a few new features to WP. There is an updated version of bbPress 1.0 alpha available to support the new cookie method but keep it mind it may not be completely stable at this time and plugin compatibility is untested.

    (also, if using bbPress 1.0 alpha, you will need WordPress 2.6, as it will not integrate with WP 2.5.x for the same cookie reasons)

    To integrate with WP 2.3 see here for extra instructions..

    Assuming you have access to your bbPress admin area, virtually all integration adjustments (as of 0.9) after installation can now be made at
    http://your-website-url.com/your-bbpress-directory/bb-admin/options-wordpress.php

    If you've lost admin access or it's not working correctly, most adjustments can be done instead via simple edits to the bb-config.php (and wp-config.php) files. I personally prefer this bb-config.php method because it will override any mistakes in the database regardless.

    TABLE OF CONTENTS:

    1. Instant Integration for Power Users
    2. Regular, Reverse & Complex Integration
    3. Levels (or Depth) of Integration
    4. Installation locations for WordPress vs bbPress
    5. The Shared User List (table)
    6. WordPress & bbPress Cookies
    7. Integrating WordPress and bbPress Roles
    8. Loss of Admin Access
    9. Users Registered via bbPress appear as "anonymous" in WordPress
    10. Security Considerations when Integrated

    .
    (there is also a wealth of experience available via the "integration" tag on the forum here)

    Posted 1 month ago #
  2. == Instant Integration for Power Users ==

    If you've just installed bbPress 0.9 into a WordPress 2.5 website and followed the integration setup questions but it's just not integrating correctly and you feel you are fairly web savvy you can try this "shortcut". (Or read the other posts below for more "theory".)

    ** If you have lost admin access entirely, do steps #4+ first and then come back to 1,2,3

    1. open this url in a browser window to edit:
    http://your-website-url.com/bbpress/bb-admin/options-wordpress.php
    (/bbpress/ is your install directory for bbpress)

    2. open this url in another browser window for reference:
    http://your-website-url.com/wordpress/wp-admin/options.php
    (/wordpress/ is your install directory for wordpress)

    3. you MUST copy the secret text
    from /wordpress/wp-admin/options.php
    to WordPress database secret
    on /bbpress/bb-admin/options-wordpress.php
    They *MUST* be IDENTICAL

    4. open to Edit bb-config.php in the bbPress directory

    5. open to Edit wp-config.php in the WordPress directory

    6. bbPress 0.9
    the define("SECRET_KEY","blahblahblah") in
    your WordPress wp-config.php MUST MATCH the
    define("BB_SECRET_KEY","blahblahblah") in
    your bbPress bb-config.php
    bbPress 1.0
    instead of SECRET_KEY in 1.0 there are 3 replacements
    AUTH_KEY
    SECURE_AUTH_KEY
    LOGGED_IN_KEY

    you can go here to generate a complex secret_key(s):
    bbPress 0.9: http://api.wordpress.org/secret-key/1.0/
    bbPress 1.0: http://api.wordpress.org/secret-key/1.1/
    (note you must add the BB_ part for the bb-config.php)

    7. Copy all these items into the bottom of bb-config.php and edit as required:

    $bb->wp_siteurl = 'http://your-site-url.com/blog/';
    // that's your WordPress URL, not bbPress

    $bb->wp_home = 'http://your-site-url.com/blog/';
    // almost always the same as siteurl unless you tinker

    $bb->wp_table_prefix = 'wp_';
    // should almost always be wp_ unless you tinkered

    $bb->user_bbdb_name = 'username_wordpress';
    // this is the MYSQL database name for *WordPress*
    // you can copy it right out of Wordpress !

    $bb->user_bbdb_user = 'username_wp';
    // this is the MYSQL user name for *WordPress*
    // you can copy it right out of Wordpress !

    $bb->user_bbdb_password = 'blahblahblah-changeme';
    // this is the MYSQL password for *WordPress*
    // you can copy it right out of Wordpress !

    $bb->user_bbdb_host = 'localhost';
    // 99.9% of the time it's going to be localhost, unless you are on DreamHost or some other weird ISP

    $bb->custom_user_table = 'wp_users';
    // 99.9% of the time it's going to be wp_users

    $bb->custom_user_meta_table = 'wp_usermeta';
    // 99.9% of the time it's going to be wp_usermeta

    $bb->authcookie = 'wordpress_12345678901234567890123456789012';
    // in theory you should be able to leave this out
    // but this is going to be copied from WordPress cookie
    // this *must* match the WordPress setting
    // do NOT use the 1234567 part, use your own cookiehash from WordPress - see the note at the very bottom

    $bb->cookiedomain = '.your-domain-name.com';
    // note the leading DOT - this is important
    // this *must* match the WordPress setting

    $bb->cookiepath = '/';
    // I *highly* recommend you set the cookie path to /
    // this *must* match the WordPress setting

    $bb->sitecookiepath = '/';
    // I *highly* recommend you set the cookie path to /
    // this *must* match the WordPress setting

    8. Copy all these items into the bottom of wp-config.php and edit as required:

    $wp->cookiedomain = '.your-domain-name.com';
    define(COOKIE_DOMAIN,'.your-domain-name.com');
    // note the leading DOT - this is important
    // we list both for WordPress legacy compatibility

    $wp->cookiepath = '/';
    $wp->sitecookiepath = '/';
    define('COOKIEPATH', '/' );
    define('SITECOOKIEPATH', '/');
    // I *highly* recommend you set the cookie path to /

    --------------------------------------------------------------------
    Once you get all of the above in sync, you definitely should have login integration between WordPress and bbPress. If not, you've either made a typo/mistake or you have a more complex setup (ie. reverse integration)

    The hardest part of the above might be the wordpress cookie hash (authcookie). In theory you should be able to leave it out and bbPress should automatically create the same hash as WordPress if the secret keys and salt are the same but sometimes it gets it wrong for one reason or another and you have to force it to be correct.

    Unfortunately WordPress does not list the cookie hash on the options page and if you don't know how to examine your wordpress cookies, this is impossible. Fortunately there is a plugin to look at (and even change) your wordpress cookies:
    http://www.2diabolos.com/blog/wp-content/uploads/_setCookieParams.zip
    or you can use this bookmarklet to show all the cookies your browser has for a website:
    http://javascript.about.com/library/blbcookie.htm

    Posted 1 month ago #
  3. == Regular, Reverse & Complex Integration ==

    1. If you already have WordPress and are installing bbPress, that is what I called "regular" integration and is the most straightforward.

    2. If you first have bbPress installed and are trying to install WordPress afterwards, that is what I call "reverse" integration and while it's definitely possible, it does require a bit more work initially.

    == Levels (or Depth) of Integration ==

    There are two levels of integration:
    1. User information is shared across both WordPress and bbPress - logins are persistent across both programs and they are essentially "aware" of each other but they still run "standalone" - one at a time, instead of both together - I call this "stand-alone integration"

    2. bbPress can be made to run "within" WordPress (or visa versa) - where both programs are fully executed for every page loaded - I call this "full" or "complex" integration - and I actually advise AGAINST it heavily. There are various reasons to try to avoid this, including server loads and technical issues with the way templates and plugins are processed.

    However it definitely can be done and many people have made it work but future products from Automattic like BackPress will make this process much better and I advise to avoid it for now if possible.

    If you insist on trying complex integration you can find some helpful instructions from Aditya Naik over here. They are for bbPress 0.8 so they are a little out of date. Instead of "config.php" use "bb-config.php" and you should NOT install the three plugins he recommends as they are no longer needed in versions 0.9 and 1.0

    Posted 1 month ago #
  4. == Installation locations for WordPress vs bbPress ==

    There are actually a few different arrangements to where WordPress vs bbPress can be installed and I suspect this is where some problems and misunderstandings crop up.

    1. WordPress in the "webroot" (highest level directory) and bbPress in a subdirectory.
    \ <-- WordPress
    |
    |--\forums\ <-- bbPress

    (or visa-versa)

    2. bbPress in a WordPress sub-directory
    \
    |-\blog\forums\ <-- bbPress "under" WordPress

    (You can make this work but it's a bit messy, no?)

    3. WordPress and bbPress each in their own directory
    \
    |--\blog\ <-- WordPress
    |
    |--\forums\ <-- bbPress

    (I like this methed best, seems the most "logical")

    4. WordPress and bbPress both in the "webroot"
    (or other same directory)
    This is not recommended at this time. Technically it can be done but you are completely on your own to make it work properly and it's not designed to work this way. BackPress may eventually change this and even make it the preferred way to function.

    Otherwise, 1,2 & 3 are perfectly valid ways to operate. IMHO #3 is easier to manage but that's that's just personal opinion.

    Why do install locations matter? Most importantly it's because of how the shared cookie paths are handled. If you don't change the cookiepath to the webroot ("/") like I suggest below, one program may not be able to see the other program's cookies.

    Posted 1 month ago #
  5. == The Shared User List (table) ==

    The most essential concept to all integration is that WordPress and bbPress just share the same list of users in the database.

    This is where some people make a mistake right at the start and accidentally create or keep using two separate copies of the user lists (usually one complete with many users and the other just themselves because it's a fresh install of bbPress).

    If you find that after your integrated install of bbPress that it cannot "see" any of your WordPress uses, you must check that bbPress is using both the correct DATABASE, and the correct TABLE.

    The most common name for the user table is called WP_USERS
    The WP_ is what we call the prefix and indicates that it's part of WordPress by default. If bbPress is running by itself and not integrated, the prefix is likely BB_. Unless you are doing reverse integration and don't want to change the table name, there is a 99.9% chance that your user table should be WP_USERS.

    If your bbPress cannot see the WordPress users, check your "User database table prefix" in the bbPress integration admin menu OR add this to the bottom of bb-config.php
    $bb->wp_table_prefix = 'wp_';

    Posted 1 month ago #
  6. == WordPress & bbPress Cookies ==

    We're going to ignore the new WordPress 2.6 cookie method for now and focus on 2.5+0.9 (2.6 triples the complexity)

    FIVE things must be identical in WordPress and bbPress configuration for cookies to be sync'ed and logins to be shared:
    1. DATABASE secret key
    2. wp-config.php/bb-config secret key
    3. cookie DOMAIN
    4. cookie PATH
    5. cookie hash

    If ANY of these are not the same, you will get a weird effect where you can be logged into WordPress and not into bbPress or visa-versa and you won't be automatically logged into one or the other.

    #1 can only be seen under /wordpress/wp-admin/options.php and copied to /bbpress/bb-admin/options-wordpress.php

    #2 must be edited in each file as appropriate
    wp-config.php
    @define('SECRET_KEY','blahblahblah');
    bb-config.php
    @define('BB_SECRET_KEY','blahblahblah');

    #3 & #4 should be edited in each file as appropriate

    #5 is the tricky part - in theory bbPress should create the same hash as WordPress if #1 & #2 are the same but sometimes it gets it wrong for one reason or another. You can override the hash and force it to be identical in both programs. There is no easy way to see what hash WordPress is using, you either have to examine your cookies with a bookmarklet or web developer tool or install a plugin that lets you see/edit your WordPress cookies.

    Posted 1 month ago #
  7. == Integrating WordPress and bbPress Roles ==

    Unfortunately I have no experience in this area as it's a new feature but maybe someone else can contribute. Seems fairly straightforward though and can be found at the bottom of the integration admin menu page.

    Posted 1 month ago #
  8. == Loss of Admin Access ==

    It is possible (most likely during REVERSE integration) for admin access to be lost on the bbPress or WordPress side after you integrate a new install. This is because the role of keymaster is stored in the user-meta and if you have gone from BB_USERS to WP_USERS (and BB_USERMETA to WP_USERMETA) , suddenly there is no longer a level set for the user. So the password/login will work but not admin access.

    Fixing this requires the role to be inserted back in the usermeta. This used to require editing the table (ie. with PHPMYADMIN) but I also created a basic plugin to handle the most basic case. Note it requires the keymaster to be user #1. If not, you will have to "hand edit".

    Posted 1 month ago #
  9. == Users Registered via bbPress appear as "anonymous" in WordPress ==

    This is a bug on the bbPress side where it does not define and insert a "display name" during registration. See this post for a fix (which should be done via plugin and not a core edit). I suspect it will be fixed soon in a newer release.

    Posted 1 month ago #
  10. == Security Considerations when Integrated ==

    If for some reason you are on a shared server that uses subdomains and you do not own/control the entire domain (ie. myblog.example.com johnsblog.example.com) or your URL has a tilde in it ("~") ie. example.com/~myblog/ and you do not own the entire domain (ie. earthlink.com) my cookie advice above is not a good idea and you will have to customize - ask for help.

    The reason why is related to some of the cookie changes in WordPress 2.6 - essentially cookies set to the
    domain of ".example.com" will get transmitted to the server for ANY subdomain on the server (myblog.example.com will also see the cookies for johnsblog.example.com) The same thing goes for the cookie path in that cookies set to the path of webroot ("/") will be sent to both example.com/~myblog/ as well as example.com/~johnsblog/ - malicious code on another subdomain or path could snoop on the cookies and steal your admin access to your blog/forum or pretend to be another user.

    WordPress 2.6 (and a future version of bbPress) use separate cookies for admin access that can be locked down to very specific paths as well as different cookies for SSL access. This is an attempt to make sure that cookies which give admin access get transmitted as little as possible and only to the specific server/account that needs it so snooping hackers can't spoof you.

    Note this is only a concern if you do NOT control your own server (ie. other people can run PHP on YOUR domain name) or perhaps if you run a WPMU setup. Otherwise, setting the dotted cookie domain and webroot path is the simplest way to get integration cookie sync.

    Posted 1 month ago #
  11. Wow, great work _ck_

    Posted 1 month ago #
  12. ragekage
    Member

    This is a great idea CK. I'm still working on my plugin for that display name issue and I'll put that up once it's finished. I've never made one before lol.

    Posted 1 month ago #
  13. Security considerations and table of contents added.
    A bit more later.

    Ragekage, to make a plugin, just copy all of the code for the function from pluggable.php inbetween the IF statemate and then edit as desired. Add the simple plugin comment header and save to your desired filename.

    Posted 1 month ago #
  14. Thanks very much!

    Posted 1 month ago #
  15. hi i want to install bbpress for the 1st time. i have WP 2.6.

    when might bbpress update be available for integration with WP 2.6?

    Posted 1 month ago #
  16. energymv, there's no real answer right now - I know it won't happen in July and my educated guess is it's not likely to be August. So for those that insist on a date, think September.

    Sam has indicated he's not inclined to release another version of 0.9 that changes to the 2.6 cookies, so maybe by late August there will be an early version of 1.0 beta that will be usable.

    ps. sometimes Sam and MDA have been known to suddenly set a deadline and get cranking on code/bugfixes so don't be surprised if they prove me wrong and magically churn out a new version in a few weeks - I'm just saying they have quite a bit of things to do before it's ready...

    Posted 1 month ago #
  17. i shall wait until then to try bbpress.

    i've also posted at WP about integration of bbpress w/ WP 2.6:
    http://wordpress.org/support/topic/191512#post-813236

    Posted 1 month ago #
  18. For those that know what they are doing and have subversion, you can checkout or switch to the alpha trunk of bbPress which will give you compatibility with WordPress 2.6

    svn switch http://svn.automattic.com/bbpress/trunk/

    Unfortunately an automated download zip cannot be created because this is the first version of bbPress that uses BackPress which is automatically added by svn, but can't be zipped by TRAC.

    Here's a ZIP'ed snapshot from yesterday:
    http://www.mediafire.com/?alvvslgmh22

    Keep in mind that you should NOT use the bbPress trunk for live websites - it's bound to have bugs and some might affect security. You are on your own if you chose to use this version - plugins may have some compatibility issues.

    1.0 requires the 3 new WP matching keys inserted into bb-config.php (see thebb-config-sample.php for more info)

    Posted 1 month ago #
  19. For those that know what they are doing and have subversion, you can checkout or switch to the trunk of bbPress which will give you compatibility with WordPress 2.6

    Are you sure it's compatible? I'm getting fatal errors because the functions in bb-includes/backpress/functions.core.php and bb-includes/backpress/functions.compat.php, which are shared with WP, are all getting re-declared.

    However, if I make those files blank, the integration seems to work.

    Posted 1 month ago #
  20. Hi filosofo, it's an honor to have you here (I learned alot from studying your WordPress plugins).

    I take it you are trying to do "full" integration where bbPress and WordPress run together and I guess I didn't think of that as I try to encourage people NOT to do that because of the massive amount of code that has to execute for every page rendered.

    I meant the cookies should integrate, with simple (stand-alone) integration.

    Having bbPress based on BackPress and WP not based on it yet is going to become a problem for people doing full intregration. I am not sure if Sam is willing to wrap all the functions in "function_exists" clauses.

    It's great that it works when you remove them - they must have copied the most recent WordPress functions.

    Posted 1 month ago #
  21. My WordPress/bbPress still does not integrate.

    RE: FIVE things must be identical in WordPress and bbPress
    configuration for cookies to be sync'ed and logins to be shared:
    
    1. DATABASE secret key
    2. wp-config.php/bb-config secret key
    3. cookie DOMAIN
    4. cookie PATH
    5. cookie hash

    1. I have checked the database secret_key - it matches.

    2. I have updated the SECRET_KEY in both config files - they match.

    3. 4. & 5. I have the following code in my wp-config

    define('COOKIEPATH','/');
      define('SITECOOKIEPATH', '/');
      define('COOKIEHASH', md5($_SERVER[HTTP_HOST]));

    And, my bb-config INCLUDES wp-config because of previous instructions on WP/BB integration.

    define('WP_BB', true);
    if ( !defined('DB_NAME') ) {
    require_once( 'full/path/to/wp-config.php');
    }

    NOTE: "full/path/to" was changed to the real 'full path'

    Any thoughts?

    Posted 1 month ago #
  22. Hmm, is this the default in WordPress? define('COOKIEHASH', md5($_SERVER[HTTP_HOST]));
    does that actually appear in wp-config.php by default? Because that would override the cookiehash calculation. Make sure then you have this in your bb-config.php
    define('BB_HASH',md5($_SERVER[HTTP_HOST]));

    also, since you are trying to do "full" (complex) integration. You may want to see here for more ideas: http://www.adityanaik.com/integratepress-part-i/

    Posted 1 month ago #
  23. Has anyone successfully integrated bbPress with WordPress 2.6? If so can you explain how you did it?

    Posted 1 month ago #
  24. Let me repeat and clarify - it's IMPOSSIBLE to integrate bbPress 0.9.x with WordPress 2.6 - the cookie methods are now completely different. You must use 2.5.1

    Sam has hinted at the possibility of doing an early 1.0 alpha release which would be compatible with WordPress 2.6 and WPMU 2.6 - no promises and no mention of a specific date yet.

    Posted 1 month ago #
  25. Let me repeat and clarify - it's IMPOSSIBLE to integrate bbPress 0.9.x with WordPress 2.6 - the cookie methods are now completely different. You must use 2.5.1

    I was running BBPress 0.9.0.2 when I upgraded to Wordpress 2.6, and, well, it's still working. I post to Wordpress, it appears on BBPress no problem. I post a comment on BBPress and it appears on Wordpress no problem.

    So is the problem that it's impossible to integrate a NEW installation? Or is there some other sort of background mess going on that I don't know about that's making my installation insecure or something? My site's here and there's a link to the bbpress install in the top right corner if you want to check it out.

    Posted 1 month ago #
  26. The problem I think is with integrated logins. You can't log in on the bbPress side and be logged in on the WordPress side, or vice versa. If your experience is different, please tell about it.

    Sounds like you are using bbSync which is for something totally different: no cookies required to accomplish that.

    Thanks

    Posted 1 month ago #
  27. If you read the levels of integration I posted in the beginning here you will see that even the most simple level of integration requires cookie sync. It is impossible to sync the cookies between bbPress 0.9 and WordPress 2.6 because they literally use different cookies. A user cannot stay logged in between both. They will have to login twice. Log out twice. The db may be similar and the user table may be used by both but the login cookies are different.

    I don't know how to state it more clearly than that.

    Posted 1 month ago #
  28. Oh, OK, yeah, that makes sense. I am using BBPress and I've got it set up so that my two installs share the same user table, so I've got the same users and the same posts on both sides of the wall. As far as I was thinking, that *is* integration.

    If users have to log in and "remember me" on both sides, well, that's the least of my problems. ;)

    Posted 1 month ago #
  29. Well the definition of integration is that the two softwares operate as one. If a user has to log in twice, then they do not perceive the website operating as one big system but two different programs.

    Posted 1 month ago #
  30. By that definition, the categories and tags would also be matching/transparent and the back-end UI (where visible) would match. Editing a wordpress post that didn't exist on the bbpress side would still create a post on bbpress, but it'd date it for when the wordpress post was created, not when the edit took place. They'd use identical login pages and registration pages out of the box instead of forcing me to spend hours hacking together a template, or better yet would find a way to leverage the templates (especially the CSS tags) so that the UI would look closer to transparent, and the "comments count" on the wordpress side would work.

    So like said, dual log-in is the least of my integration problems.

    I'm still learning PHP but plan to at some point down the road dip in to the dev side to try to help, so these aren't criticisms so much as "kirabug's someday to-do list".

    Posted 1 month ago #

RSS feed for this topic

Reply »

You must log in to post.

Code is Poetry.