Skip to:
Content
Pages
Categories
Search
Top
Bottom

WordPress + bbPress Integration 101

Viewing 25 replies - 126 through 150 (of 191 total)

  • _ck_
    Participant

    @_ck_

    Yes that configuration is certainly possible.

    The same logic applies, both cookies need to be using the webroot as the path.


    razorcreed
    Member

    @razorcreed

    would this work with 2.7? and is there any install documentation of doing it this way?

    To include the wordpress theme I simply included the header and footer files into the bbpress themes (deleting the rest of content in there) and then added the login to the header in the wordpress theme using <? if (function_exists(‘bb_login’)) ?>

    You can see this at http://superturbodiesel.com/. The only problem I found was that you can’t login from the wp home page. In my case this is perfect as forum administrators are the only ones who can post in WP.


    lorenzocoffee
    Member

    @lorenzocoffee

    hi winmutt

    did you also implementes the cross posting ?

    I mean post an article in the blog and automatically doubbing it on the forum?

    thanks

    No, I did not want that functionality at all. My post was simply an easy way to integrate an existing wp theme.

    RE PHP4 post earlier, php4 is all but deprecated, its EOL has already passed, tell your host to upgrade!!!!


    Marcomail
    Member

    @marcomail

    with wp 2.7 which version of bbpress i should use ?


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    @marcomail

    bbPress 1.0 alpha 4


    briandbutler
    Member

    @briandbutler

    HELP!

    mine was almost working… I upgraded to wpmu 2.7, and bbpress1.0 alpha 4…. the data base was sharing…everything was almost perfect….but then….

    I was in the Admin Panel for bbpress, and was changing User roles (admin of wp to be admin of bbpress, etc)….

    Then, I saw that the ‘SECURE_AUTH_SALT’ form was blank…. (in the admin panel of bbpress for wordpress integration)… I thought …”mmm., thats strange, I already entered that when doing the setup.!”…. so…..i entered the key again …..

    oops, really bad idea

    Now, i get an error message:

    Warning: mysql_connect() [function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2) in /nfs/c02/h03/mnt/27695/domains/globotrends.com/html/forums/bb-includes/backpress/class.bpdb.php on line 123

    Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /nfs/c02/h03/mnt/27695/domains/globotrends.com/html/forums/bb-includes/backpress/class.bpdb.php on line 377

    HELP!!!!!!

    how do i undo what i did?

    where do I look? in what file?

    my sites are here:

    1. bbpress: http://globotrends.com/forums

    2. wpmu: http://globotrends.com/community


    briandbutler
    Member

    @briandbutler

    i mean…bbpress. alpha6 (not 4)


    netcompetency
    Member

    @netcompetency

    I followed some of these instructions and completely integrated WP 2.6.2 and bbPress 0.9 logins on my site today (BayAnime.com). I’d already had 2.6 up and running when I installed bbPress and didn’t want to roll back (I really need to roll forward at some point), so I just copied and pasted all the old WP 2.5 cookie functions from pluggable.php into a separate plugin file for my 2.6 install, set all the paths and keys, and it’s working well. I expect you can just do the same with WP 2.7 if you want to integrate it with bbPress 0.9. Anyway just wanted to report that it IS possible to get 2.6 (and up probably) working with bbPress 0.9 without too much more pain. If anyone’s interested in the plugin file that has the WP 2.5 functions you need, just let me know!


    _ck_
    Participant

    @_ck_

    First post updated to reflect the two new plugins available to allow WP 2.6, 2.7 or 2.8 to work with bbPress 0.9

    If you’re seeing WP logins work, and BB logins fail, then BB is probably logging you in and setting the wrong cookie path.

    (You can debug this sort of thing by using a proxy which lets you inspect the headers as they pass from client to server – I recommend the excellent Charles Web Debugging Proxy.)

    I fixed this using the WP Cookie Root plugin. Changing the COOKIE_PATH defines for me hadn’t worked, but the plugin did.

    http://wordpress.org/extend/plugins/root-cookie/

    Q: With deep integration, I see any postings to BB get double-quoted, eg an apostrophe posted to the forum will appear as ‘ …

    Here’s hoping BBPress doesn’t munge the line above. Apostrophes appear in the forum with a backslash to escape them, because both WP and BB are running the apostrophes thru their escaping function. How can I avoid this?


    andyimages
    Member

    @andyimages

    So far I am failing on this. I am going to try the plug-in that xurizaemom has suggested…..my integration is failing and I have tried the suggested method running WP 2.7 and the latest bbpress 0.9.0.4 .

    There is definitely some conflict between the cookies as if I login as admin on wp, then go to bb, clicking on the admin link fails and I am redirected to the front page instead of admin area. Logged out of WP, and logging into BBPress as admin, the link works properly and the admin panel opens…

    The wordpress is in the the root directory and bbpress in its own directory in the root.


    _ck_
    Participant

    @_ck_

    andyimages, to use WP 2.7 with bbPress 0.9 you need one of the two plugin solutions now updated in the first post. Changing the cookie path is not enough, you have to change the cookie method entirely.


    andyimages
    Member

    @andyimages

    CK I installed the plugin with the salt keys, etc……and there is evidentally a little progess as the cookies do not conflict as before, but the integration hasn’t worked either. Not sure what the issue is but in the docs there are not a precise definition of the secret key. Is the database secret key that you refer to the key I have defined in the config, php that holds the database name, password, etc…..or is that the “secret,” randomly derived string that is listed through options.php as “secret”? Also, since I am using .9, where exactly are the bbpress integration settings in wp……there was a new-plugin, but that was for 1. alpha, right…..not for .9?

    Excuse me because I am new to this, but does it make sense for me to upgrade to the alpha version, is that easier to integrate? Or do I want to go the other direction and downgrade the wp cookies.

    Thanks in advance>>

    Andy


    _ck_
    Participant

    @_ck_

    Do not even “try” the alpha as you can then never go back to 0.9

    Many plugins will not work with the alpha and won’t for some time.

    You want to downgrade the wp cookies. Use Ann’s plugin.


    andyimages
    Member

    @andyimages

    Got the problem…..when copying the secret from the options.php in wordpress to enter into the WP INtegration in BBpress, on submit bbpress (or something) was stripping the final character off the secret string. I checked this twice to make sure it was happening, and then edited the record by just pasting in the “).” Voilla. Ann’s cookie worked!

    Btw, when you do cookie integration please keep in mind that there are some login hooks in pluggable that might not be called in either WP or bbPress depending on which side your user logged in from. This might affect the functionality of some plugins.

    For example, after rerouting all my bbPress logins to WP I realized that the ‘bb_set_current_user’ action hook on a bbPress plugin I used was no longer being called, so I had to incorporate it in on the WP side using the ‘set_current_user’ hook.


    andyimages
    Member

    @andyimages

    Thanks Ann, so far so good…..no problems on that end.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    How I do deep integration using WordPress 2.7 and bbPress 1.0 Alpha 6.

    Add to beginning of bb-config.php:

    if ( !defined('ABSPATH') & !defined('XMLRPC_REQUEST')) {
    define('WP_USE_THEMES', false);
    include_once( '/absolute/path/to/yourdomain.com/wp-blog-header.php' );
    header("HTTP/1.1 200 OK");
    header("Status: 200 All rosy");
    }

    I tried integrating bbPress (alpha 6) with 2.7 WP MU and ran into problems. The web-based installation failed if I selected integration (I left the “Add cookie integration settings” unchecked, only tried user database integration) – it threw up an error during the last step, and said Installation Halted! (although all previous tests and validations seemed to go through fine).

    I dropped the bb_ tables, then installed bbPress without the integration options and it worked. Is it possible to modify a working bbpress installation to integrate with WP MU after installation? Has anyone done this before – and might have instructions online somewhere?

    All on dreamhost.com server.

    @_ck_:

    A note on deep integration: As of 0.9.0.4, deep integration will break the localization due to the localization methods being used from WP’s core files (bb_settings.php line 75), causing the system to look for bbPress-language files in the WP language directory. Here’s what to fix to make bbPress load it’s own language files from bb_includes/languages when using deep integration:

    In line 376-377 of bb-settings.php, replace

    // Load the default text localization domain.
    load_default_textdomain();

    with

    // Load the default text localization domain.
    if ( !(defined('DB_NAME')) ) { // Include localization the bbPress-way when WP is not running.
    load_default_textdomain();
    }
    else {
    $locale = get_locale();
    $mofile = BB_LANG_DIR . "$locale.mo";

    load_textdomain('default', $mofile);
    };


    Billy Schneider
    Member

    @bananastalktome

    Hey all. After much help from reading these forums and tinkering endlessly, I have gotten cross site logins working between WP2.6 and bbpress 0.9 . I don’t know if you’d call it ‘integration’, but it allows a user to log in once and gain access to all appropriate site resources. Although probably not the best solution, what I did is create my own cookie login, which is caught before wordpress or bbpress load, and creates a new user object which is universal to WP and BBPress (and any other webapps you use). It does take a little…alteration…of core WP and BBPress files. I strongly encourage you to make backups before doing this, and proceed at your own risk. It worked for me, but I cannot guarantee that it will fork for you. Also, it took a bit of hacking before I came up with this solution, so it may contain minor errors or accidental omissions as I am having to backtrack to recall what exactly I did.

    okay, here goes…

    First, we have to configure bbpress to use the wp_users table. That is done in the admin area of bbpress (settings->wordpress integration). Check ‘Show Advanced Database Settings’ and enter your database information for the wordpress install. Also, enter the wordpress database secret code near the top of the settings page.

    Next, I created a file in the document root called ‘cookie_login.php’:

    <?php
    if($_SERVER['REQUEST_URI'] == '/cookie_login.php'){die('Cannot access directly');}

    //Initial Setup of Variables
    $SECRET_KEY = 'SECRET_KEY_DEFINED_IN_BBPRESS_AND_WP';//use a real secret key
    $site_user = false;

    //Do the DB thing
    $the_db= mysql_connect('SERVER','USER','PASS');
    mysql_select_db('DATABASE',$the_db);

    //Start Session!
    session_set_cookie_params(1800,'/','.SITE.com'); //30 minute session
    session_start();
    if (isset($_COOKIE['site_cookie'])){ //cookie has been set, proceed to get user info!
    $tmp = explode(':',$_COOKIE['site_cookie']); //this will make sense later
    $tmpusr = $tmp[0];
    $wpid = $tmp[1];
    $tmphash = $tmp[2];
    $hashShouldBe = md5($tmpusr . $SECRET_KEY . $wpid); //what the hash should be - prevent tampering!
    if ($tmphash == $hashShouldBe){
    if (isset($_SESSION['user'])){
    $site_user = $_SESSION['user'];
    }else{
    $qry = "SELECT * from wp_users WHERE ID = ".mysql_real_escape_string($wpid,$the_db) . " LIMIT 1";
    $result = mysql_query($qry,$the_db);
    $site_user = mysql_fetch_assoc($result);
    $qry = "SELECT meta_key, meta_value from wp_usermeta where user_id = ".mysql_real_escape_string($wpid,$the_db);//get additional data, just for fun
    $resulta = mysql_query($qry,$the_db);
    $temp_arr = array();
    while ($row = mysql_fetch_assoc($resulta)){
    $tmp_value = unserialize($row['meta_value']) ? unserialize($row['meta_value']) : $row['meta_value'];//if it a serialized array, unserialize it. otherwise, dont.
    $temp_arr[$row['meta_key']] = $tmp_value;
    }
    $site_user = $temp_arr + $site_user;
    $_SESSION['user'] = (object)$site_user;//Object just out of preference, but doesn't have to be
    }

    }else{//tsk tsk, bad hash
    $_SESSION['user'] = array();
    setcookie('site_cookie',$_COOKIE['site_cookie'],time()-9600,'/','.SITE.com');
    setcookie('PHPSESSID',$_COOKIE['PHPSESSID'],time()-9600,'/','.SITE.com');
    setcookie(session_name(), session_id(), time()-9600, '/');//may be unnecessary...not sure...but can't hurt! (famous last words)
    session_destroy();
    }
    }
    if (!isset($_COOKIE['site_cookie']) && isset($_SESSION['user'])){//attempt to gain access?
    $_SESSION['user'] = array();
    setcookie('site_cookie',$_COOKIE['site_cookie'],time()-9600,'/','.SITE.com');
    setcookie('PHPSESSID',$_COOKIE['PHPSESSID'],time()-9600,'/','.SITE.com');
    setcookie(session_name(), session_id(), time()-9600, '/');//may be unnecessary...not sure...but can't hurt! (famous last words)
    session_destroy();
    }
    session_write_close();
    unset($SECRET_KEY,$hashShouldBe,$tmp,$wpid,$tmphash,$tmpusr,$result,$_SESSION['user'],$resulta,$temp_arr);//burn the evidence!
    include ('site_functions.php'); //optional, can hook another file with functions (universal to all sites) to deal with this new user object
    ?>

    After I finished the cookie_login.php, I rolled up my sleeves and dove into the WordPress and BBPress core to allow my login to occur.

    in the /wp-config.php file, define the cookie domain:

    define('COOKIE_DOMAIN', '.SITE.com');

    Also, that secret key you used earlier in cookie_login…define it here as well

    define('SECRET_KEY', 'Same Key from Earlier. IMPORTANT to make sure it's identical');

    Next, I hooked in my cookie_login file to wordpress and bbpress by adding an include to the top of BOTH bb-config.php AND wp-config.php

    include $_SERVER['DOCUMENT_ROOT'] . '/cookie_login.php';

    To set up the ‘site_cookie’ properly, open up /wp-includes/user.php and find wp_signon function (was the first one for me). At the bottom of the function, after

    if ( is_wp_error($user) )
    return $user;

    Add the following:

    $hashValue = $credentials['user_login'] . SECRET_KEY . $user->data->ID;
    $crossCookieValue = $credentials['user_login'] . ':' . $user->data->ID . ':' . md5($hashValue);

    setcookie('site_cookie',$crossCookieValue,0,'/','.SITE.com');
    wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie);
    do_action('wp_login', $credentials['user_login']);//this may have already been there, don't remember

    Remember how I mentioned the site_functions.php which can be included at the bottom of cookie_login.php? That is a perfect place to put the next function, for bbpress login, but it can just as well go inside cookie_login.php itself. The function overwrites the bbpress native wp_validate_auth_cookie function, found in /bb-includes/pluggable.php, with one of our own, which is as follows:

    function wp_validate_auth_cookie($cookie = '') {
    global $site_user;
    if (!isset($site_user->ID)){
    return false;
    }else{
    return $site_user->ID;
    }
    }

    This is used internally by bbpress to allow the login to proceed.

    Next, open /wp-login.php and find the case: logout section, and add the following right after it:

    setcookie('site_cookie',$_COOKIE['site_cookie'],time()-9600,'/','.SITE.com');
    setcookie('PHPSESSID',$_COOKIE['PHPSESSID'],time()-9600,'/','.SITE.com');'

    Finally, and this may be only applicable for subdomain usage, open /wp-includes/pluggable.php and find the function wp_safe_redirect. Add subdomains you want redirects to in the $allowed_hosts array, for example:

    $allowed_hosts[]=”bbpress.SITE.com”;

    $allowed_hosts[]=”test_wordpres.SITE.com”;`

    etc…

    That’s all (I think) that I had to do. This is probably not ideal, as there are now two copies of a user when hey login, one defined in our new system and one in the wordpress/bbpress systems; however I found this necessary to have happen since I didn’t want to go through all the core code and edit out mention of $user.

    Let me know if this works for you, I hope it was coherant enough. I may have accidentally omitted sections since, as I said before, this is the result of a few weeks of on-and-off tweaks and changes. I can always dig into code and find things I missed if I know what problems are occurring. Also, if anyone is interested, I altered a private messenging system I found which was a little outdated (http://www.pixel2life.com/publish/tutorials/608/simple_private_messaging_system/) to work with this model as well. Users can PM one another from within the wordpress dashboard, and message indicators are noted in the header throughout their visit (in wordpress, bbpress, and other subsites).

    I have uploaded the bbpress in my server. and i get the 1st welcome installation screen. After i press “lets get started” .i get the following error…

    “Warning: html_entity_decode() expects parameter 2 to be long, string given in /home/hnsalumn/public_html/ryt/bbpress/bb-includes/wp-functions.php on line 113″

    Please HELP ! ( i have already installed wordpress MU in the server.)

Viewing 25 replies - 126 through 150 (of 191 total)

The topic ‘WordPress + bbPress Integration 101’ is closed to new replies.