Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP Avatars in bbPress

  • Avatar of Gogoplata
    gogoplata
    Participant

    @gogoplata

    Is it possible to display the avatars uploaded in BuddyPress in bbPress (integrated with WPMU, but not using bp-forums)? If so, how?

    TIA

Viewing 25 replies - 1 through 25 (of 76 total)
  • Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    I’m doing this via the bbGroups plugin, and some pretty in depth modifications to the bbPress theme.

    I’m working on and off with Burt to try and pass BuddyPress xprofile info to bbPress, as my goal is probably the same as yours and most others; to have all information match across the entire website.

    We’re working towards that goal, hopefully soon. :)

    Avatar of Gogoplata
    gogoplata
    Participant

    @gogoplata

    Didn’t realize avatar sharing was part of that plugin, will check it out. Thanks!

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    John, I haven’t had time to even delve into the xprofile code yet. I’m going to start working on bbGroups again this evening. There are some ‘tags’ issues poping up I have to work on. If you’ve accomplished the xprofile fields being added I’d love to see how and add it to the plugin if you are so inclined to donate to the effort. If not then I can take a look at that. Let me know.

    Oh. I added the ‘editor’ role for the community blogs plugin as you suggested.

    http://code.ourcommoninterest.org/

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Burt, I will for sure let you see how I did it, but I’ll admit it isn’t a universal method. I hard coded the fields I wanted to pass to bbPress just to make it work in the interim, and it doesn’t work yet for members that aren’t in any groups.

    I’m mobile right now but when I get home tonight I’ll rejoin and show you what I did.

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    Ya you did mention profile data getting to bbpress from bp for users without groups. I don’t see any reason not to do it. The privacy elements rely on the user having a list of their forums in the bb meta data that comes across from bp. No forums means no access. I’ll add that too since I’m now fooling around in that area. Gonna mean some changes to the import routine. I’ll work on it.

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    That’s awesome. Your hard work is appreciated very much. :)

    Did you still want to see what I was trying to do, or do you think you have a good handle on it?

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    Of course I’d like to see it John. I still haven’t looked at xprofile yet. :)

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Burt, I’m going to get at this tomorrow with you if that’s cool. It’s late here and I’ve got an early wake-up tomorrow, ugh…

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Well, while the GF is in the shower, I’ll quick do this… Burt this is aimed directly at you, since I gather most others won’t want to do this kind of thing…

    oci_bb_group_forums.php:


    This prevents wrong inclusion order when using deep forum integration.

    if (defined(BACKPRESS_PATH))
    require_once( BACKPRESS_PATH . '/class.ixr.php' );

    This will return ALL user info, in the event that bbGroups does not exist yet for that user.

    function oci_get_userdata($u){
    $u = (int) $u;
    $user = bb_get_user($u);
    if ($user->bbGroups) {
    return stripslashes_deep((array)$user->bbGroups);
    } else {
    return stripslashes_deep((array)$user);
    }
    }

    oci_bp_group_forums.php:


    This prevents wrong inclusion order when using deep forum integration.

    if (!defined(BBDB_NAME))
    require_once(ABSPATH . WPINC . '/class-IXR.php');

    This is how I passed the user info over from xprofile to bbGroups:

    /**
    * oci_get_user_filter()
    *
    * Live example of how to use the filter mechanism to add info to the data going across to bbpress
    * This filter adds the user's forums and forums where the user is staff into the $user array
    * @return
    * @param associative array $user from oci_get_user()
    */
    function oci_get_user_filter($user){
    $users_group_info = oci_get_users_group_info($user['id']);

    $user['users_forums'] = $users_group_info['forum_ids'];
    $user['user_is_staff'] = $users_group_info['staff_ids'];

    $user['custom_title'] = bp_get_field_data('Custom Title', $user['id']);
    $user['signature'] = bp_get_field_data('Signature', $user['id']);
    $user['aim'] = bp_get_field_data('AIM', $user['id']);
    $user['yahoo'] = bp_get_field_data('Yahoo!', $user['id']);
    $user['gtalk'] = bp_get_field_data('GTalk', $user['id']);
    $user['msn'] = bp_get_field_data('MSN', $user['id']);
    $user['jabber'] = bp_get_field_data('Jabber', $user['id']);
    $user['icq'] = bp_get_field_data('ICQ', $user['id']);

    return $user;
    }
    add_filter('oci_get_user','oci_get_user_filter',10,1);

    oci_bb_custom.php


    How I transfer the username (just in case fullname hasn’t been edited from wordpress.org transfer – see above oci_get_userdata changes):

    function oci_user_name($u){
    $bp_user = oci_get_userdata($u);
    if ($bp_user['fullname']) {
    return $bp_user['fullname'];
    } else {
    return $bp_user['display_name'];
    }
    }

    bbpress/active-theme/functions.php


    What I added to make the custom functions go:

    add_filter('get_user_profile_link', 'bppro_user_profile_link', 10, 2);
    function bppro_user_profile_link($link, $uid) {
    $user = bb_get_user($uid);
    return(bb_get_option('wp_siteurl').'/members/' . $user->user_login);
    }

    function bppro_user_url() {
    global $bp;
    return($bp->loggedin_user->domain);
    }

    function bp_check_title($user) {
    $user_id = get_post_author_id();
    $user = bb_get_user($user_id);
    $user_title = $user->bbGroups['custom_title'];

    if ($user_title) {
    return $user->bbGroups['custom_title'];
    } else {
    return;
    }
    }
    add_filter('post_author_title', 'bp_check_title');
    add_filter('post_author_title_link', 'bp_check_title');

    function post_author_signature() {
    $user_id = get_post_author_id();
    $user = bb_get_user($user_id);
    $user_signature = $user->bbGroups['signature'];

    if ($user_signature) {
    echo '<p class="post-signature">__________<br />' . $user->bbGroups['signature'] . '</p>';
    }
    }

    bbpress/active-theme/post.php


    Displays avatar from BuddyPress if it exists, else bbPress/Gravatar. Also displays hooked data from above functions.php:

    <div class="threadauthor">
    <dl>
    <dt><a class="oci-link" href="<?php echo oci_user_link($bb_post->poster_id); ?>"><?php echo oci_user_name($bb_post->poster_id); ?></a></dt>
    <dd><span class="oci-title"><?php $patl = post_author_title_link(); ?></span></dd>
    <dd><?php if (oci_user_avatar($bb_post->poster_id)) { echo oci_user_avatar($bb_post->poster_id); } else { post_author_avatar_link(); }?></dd>
    </dl>
    </div>
    <div class="threadpost">
    <div class="poststuff">
    <?php printf( __('Posted %s ago'), bb_get_post_time() ); ?> <a href="<?php post_anchor_link(); ?>">#</a> <?php bb_post_admin(); ?><?php bb_quote_link(); ?>
    </div>
    <div class="post">
    <?php post_text(); ?>
    </div>
    <?php post_author_signature(); ?>
    </div>

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    Thanks John. I’m doing some upgrades to the bbGroups thing today and I’ll integrate what I can into the plugin. I’m thinking a generic oci_include_xprofile_field() function that takes a field name and if it exists includes it in the transferred data.

    The deep integration stuff will be included. bbPress has a deep detector and constant defined that changes it’s behavior if it’s ON. Don’t do this, do that different if DEEP. I’m going to follow the same path as sambauers. The results will be the same as yours.

    if (DEEP) require_once(…);

    p.s It’s not called DEEP.

    NOTE: not done talking just saving.. :)

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    I think that makes perfect sense. Don’t forget to make functions for both getting the profile data, and then displaying it back out to bbPress also. I wanted to try and make a function that would either filter or not filter the output, so that I can hook into the field name and decide whether it’s HTML (like a signature) or plain text (like a custom title.)

    I thought bbPress had a deep indication, but I couldn’t find one that worked without me telling it what to keep an eye out for.

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    OK. I’m back. The bbpress const for wordpress is: BB_IS_WP_LOADED and is defined in bb-settings.php John. Looks like it’s only being used during installation and bbpress boot.

    Thanks for reminding me about the template tags. I’ll include those too. I’ll add filters to all the template tags also. Good idea.

    Many thanks for your help and sharing!

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    One of the consts I check for is on the WPMU side also, looking to see if BBP is included already as part of the circle. WPMU doesn’t have a const to tell it if bbPress is included inside it, that’s why I used pre-existing unrelated consts, so that I know that they haven’t been tainted by each others inclusion in either direction.

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    I like the inclusion of ‘signature’ in a profile field! Nice idea.

    I’ve updated bbGroups to optionally transfer all users over to bbpress meta or just users who are in groups. Skipping the bbpress/buddypress utility user.

    I’ve got all xprofile groups and group field values going to bbpress.

    Got a template tag that allows getting any of those values by user, group, field.

    Did some cleanup internationalization for text.

    Now doing testing. Gotta look into the problem with tags for hidden groups showing up in the tag cloud. I don’t think you’d be interested in any of this. You’ve already got that stuff implemented. :)

    I think that the only mod of yours I stepped on was the oci_get_user_filter() changes you included in there. I added another filter function oci_get_xprofile_filter($user) that adds all the xprofile fields to the $user array. It won’t break your mod, it’ll just add all the xprofile fields again.

    /**

    * oci_get_xprofile_filter()

    *

    * This filter adds all xprofile groups and group fields to bbpress

    *

    * @param <array> $user

    * @return <array> $user array for xmlrpc transport

    */

    function oci_get_xprofile_filter($user){

    $xprofile_groups = BP_XProfile_Group:: get_all(true); // all except empty groups

    foreach($xprofile_groups as $group){

    foreach($group->fields as $field){ // all fields for group

    $field_obj = new BP_XProfile_Field($field->id, $user,true); // this field

    // xprofile_groupname_fieldname to prevent conflicts

    $user = array(‘group’ => $group->name, ‘name’ => $field_obj->name, ‘value’ => $field_obj->data->value, ‘type’ => $field_obj->type);

    }

    }

    return $user;

    }

    add_filter(‘oci_get_user’,’oci_get_xprofile_filter’,10,1);

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Well, yes I do, but I’d like it done the right way, and I suspect your way will be better than mine. :)

    If you want some help putting it through the motions, I’ll gladly take some time tomorrow to work your new version into mine. :D

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    Hi John. :)

    I have to test the xprofile stuff on the bbpress template tag level. I think I’m transferring data that could be serialized in $field_obj->data->value. Gotta check that.

    This thing needs chat. You ever on IRC? A bunch of us hang out in irc.freenode.net #buddypress. I’m always there.

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Cool cool… Can’t wait… I love it! Woo hoo!

    Avatar of Burt Adsit
    Burt Adsit
    Participant

    @burtadsit

    I think I have the deep stuff grok’ed. wp loads first and then bbpress. So just this in the bbpress plugin should work:

    if (!defined(BB_IS_WP_LOADED))

    require_once( BACKPRESS_PATH . ‘/class.ixr.php’ );

    Well, that’s what’s in there. I can’t test it. Relying on you to tell me if it works ok.

    v0.3 at http://code.ourcommoninterest.org in a few minutes.

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Awesome, will check it out today.

    On an interesting side note, somewhere along the line I broke my connection from BuddyPress to bbPress again. Ha! I need to stop fidgeting with things soon I think. ;)

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Burt…

    When accessing the forums using deep integration, with no modifications to your updated plugin…

    Fatal error: Cannot redeclare class IXR_IntrospectionServer in /homepages/8/d149961498/htdocs/delsolownersclub/discussions/bb-includes/backpress/class.ixr.php on line 860

    Think of the loop that’s happening… bbPress loads WordPress, loads ixr, which continues to load bbPress. I really do think both sides need to check to see if the other is included to ensure this doesn’t happen.

    Going back to oci_bp_group_forums.php and putting

    if (!defined(BBDB_NAME))
    require_once(ABSPATH . WPINC . '/class-IXR.php');

    and then back to oci_bb_group_forums.php and putting

    if (defined(BACKPRESS_PATH))
    require_once( BACKPRESS_PATH . '/class.ixr.php' );

    Fixes this.

    Let me find where they are declared and try to walk you through the deep integration dance. It’s a pain in the butt, but it works. I don’t see any other way to get things like the BuddyBar and all of the BP functions over to bbPress without deep integration.

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Okay, I attempted to import all users, and got this…

    Groups with forums enabled - , Forums updated - , Users updated -

    Checking to see what happened now…


    Looks like nothing happened. No one got their bbGroups like they should have. Going to keep looking…

    Importing only groups doesn’t do anything either… Still checking…

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    When I do the $burt variable debug trick, it looks like http://delsolownersclub.com/discussions/xmlrpc.php is pulling a 404 again like it was before over here http://buddypress.org/forums/topic.php?id=426, but it’s very clearly there, and nothing else appears to be in the way.

    Arg… Still looking…

    Arg… It broke somewhere before I even was playing with this.. I reverted everything back to the previous version (.23 I believe) and while I can get forum post info, for some reason I can’t post anything.

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    So if I use your test rig Burt, I get a 403 Authentication Failed response… wtf… Ha!

    But if I revert back to .23 and click on “Import Groups” it gets…

    Last import Tuesday 03rd of March 2009 03:32:03 PM, 2 seconds

    3 groups with forums enabled

    3 forums updated

    12 users updated

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Okay, somehow the password in my BP Site Admin -> bbPress Forums got corrupted…

    omg…

    Crisis averted…

    Lets try this again…

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Okay after all of my tizzying around, I still get this when I try to import…

    Groups with forums enabled – , Forums updated – , Users updated -

Viewing 25 replies - 1 through 25 (of 76 total)

You must be logged in to reply to this topic.