Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP Avatars (and nothing else!) in bbpress… possible?

  • Hello, doing searches and reading, I’ve seen plenty of discussion on deep integration and pulling various BP features into bbpress. Most of the answers seem to be to add a plugin for groups, or do the full-on integration.

    However, what I would like to know is if there is a way to have bbpress display the BP avatar for a user, and if they don’t have that either leave it blank (mystery man) or a gravatar or whatever. Basically, if the user has an avatar uploaded in BP, have it show up in bbpress.

    That’s ALL I want to do. I don’t need any other integration, I don’t want group forums, just the avatar. Is there a way to do that? The version of bbpress doesn’t matter, I’ll change to whatever version I need to in order to make it work.

Viewing 23 replies - 1 through 23 (of 23 total)
  • @burtadsit

    Participant

    Well, you could take the fn bp_core_get_avatar() in bp-core-avatars.php, rework it a bit to get the bp avatar and operate in bbpress. The avatar path, if one exists, lives in user meta which is reachable from bbpress without deep integration or a plugin of any sort.

    Thanks for the answer, Burt. Sounds like it wouldn’t be too difficult for someone that knew what they were doing… but lost on a non-coder like me.

    In the default bbpress theme (kakumei), I found post.php which has:

    <div id="position-<?php post_position(); ?>">
    <div class="threadauthor">
    <?php post_author_avatar_link(); ?>
    <p>
    <?php post_author_link(); ?><br />
    <small><?php post_author_title_link(); ?></small>
    </p>
    </div>

    Would it be something like replacing “post_author_avatar_link();” with “function bp_core_get_avatar( $user, $version = 1, $width = null, $height = null, $no_tag = false ) ” from bp-core-avatars.php?

    That seems too easy, so I doubt that’s it. Does anybody have a few minutes to type out a quick how-to?

    @johnjamesjacoby

    Keymaster

    No, not that easy unfortunately. The best way is to use “deep integration” so that you have all of the BuddyPress functions available for bbPress also.

    Otherwise you’d be wise to use Burt Adsit’s bpGroups plugin, and import the user bases extended profile information.

    Right….

    Is there a way to do a “light” integration that will only do the avatars without doing all the other mess and without the plugins that do everything else??

    @johnjamesjacoby

    Keymaster

    It would require to make some kind of plugin for bbPress.

    The drawback of this ends up to still be the additional query per avatar that you hit the database server with, to ask BuddyPress what each users avatar is for each visible avatar. It might be possible to hook a bbPress function and join the query together to include the extended profile table to get the avatar location, but this type of thing hasn’t been developed or released yet.

    @rebootnow

    Participant

    Here is a quick & dirty stab at the method Burt suggests above. I have modified “bp_core_get_avatar()” (from “bp-core-avatars.php”) for use bbPress. Like the bp function it uses an uploaded avatar or a gravatar. You need to ensure that there is a “mystery-man.gif” file in the images folder of your theme. Note that I haven’t enabled the fancy automatically generated avatars.

    It works for me. Here are the steps:

    Create the new function “_get_avatar()”. I put it in “functions.php” in my theme folder and added “<?php require_once( ‘functions.php’ ); ?>” just before the <body> tag in “header.php” to ensure that it was loaded.

    You need the following in your “post.php” to call the function:

    <?php echo _get_avatar( get_post_author_id() ); ?>

    Here is the code for “_get_avatar()”:

    function _get_avatar( $id ) {

    $avatar_file = bb_get_usermeta( get_post_author_id(), ‘bp_core_avatar_v1’ );

    $url = BB_PATH . $avatar_file;

    if ( strlen( $avatar_file ) ) {

    return ‘<img src=”‘ . attribute_escape( $url ) . ‘” alt=”” class=”avatar photo” width=”50″ height=”50″ />’;

    } else {

    $default_grav = bb_get_active_theme_uri() . ‘images/mystery-man.gif’;

    $user_email = bb_get_user_email( $id );

    $gravatar = ‘https://secure.gravatar.com/avatar/&#8217; . md5( $user_email ) . ‘?d=’ . $default_grav . ‘&s=50’;

    return ‘<img src=”‘ . attribute_escape( $gravatar ) . ‘” alt=”” class=”avatar photo” width=”50″ height=”50″ />’;

    }

    return;

    }

    One question I have for the experts… Is this a reasonable way of adding a new function? Or would it be better to create a plugin. I didn’t do the latter because I didn’t need to use any of the hooks.

    @burtadsit

    Participant

    Cool. Anyway you get your function into the mix is a ‘reasonable way’ of adding it. Unfortunately bbpress doesn’t have the concept of a functions.php like wp does in it’s themes. The only other alternative you have is a plugin. The plugin makes it available no matter what theme the user has selected. That’s the big difference.

    @johnjamesjacoby

    Keymaster

    Burt, I am fairly certain that bbPress allows for functions.php the exact same way that WordPress does. Including it in the header shouldn’t be necessary. Unless this changed recently and I wasn’t paying attention?

    @burtadsit

    Participant

    Really? Well that would be useful. I took a quick look in Kakumei and didn’t see such an animal so I figured it didn’t exist.

    @rebootnow

    Participant

    John, FWIW, I tried just creating a functions.php and the function wasn’t found.

    @r-a-y

    Keymaster

    Hmm… Reboot Now, that’s interesting because my functions.php file seems to work in my bbPress theme. I’m using the functions.php file to call on the BP admin bar and it works.

    FYI, I’m using bbPress 1.0 alpha 6 and the default Kakumei theme.

    Just tried your _get_avatar() function and it works!

    Instead of mystery-man, I defaulted it to wavatar.

    Thanks!

    @korhanekinci

    Participant

    YOU ARE THE BEST REBOOT NOW! It worked for me too!!!

    @rebootnow

    Participant

    No problem. Thanks Burt for the idea.

    BTW, I realized why functions.php wasn’t working by default in my case. I am currently integrated with BBP 0.9.0.5, which didn’t have this feature – it was introduced in 1.0.

    @korhanekinci

    Participant

    Just one more thing: I am using facebook connect plugin and once I did as you said, members who sign up through their facebook account get empty avatar now. It used to be their facebook avatar…

    UPDATE: Actually I just checked the demo site and facebook avatars dont show there either, so the problem is the plugin I guess?!

    How can that be fixed?

    Thanks in advance

    @rebootnow

    Participant

    Sorry, I haven’t experimented with the facebook connect plugin.

    @korhanekinci

    Participant

    r-a-y

    Instead of mystery-man, I defaulted it to wavatar.

    How did you do that r-a-y? I also would like to do it

    @r-a-y

    Keymaster

    korhanekinci,

    Change this line:

    $default_grav = bb_get_active_theme_uri() . 'images/mystery-man.gif';

    to:

    $default_grav = 'wavatar';

    @korhanekinci

    Participant

    thanks so much

    @gerikg

    Participant

    if you did the deep integration you just need to put

    <?php echo bp_core_get_avatar( get_post_author_id() ); ?>

    without editing core files (you might forget you edit them when you upgrade.)

    @alexduvot

    Participant

    anyone has a working plugin or instructions

    @gerikg

    Participant

    Yes,

    Open post.php replace

    <?php post_author_avatar_link(); ?>

    with

    <?php echo bp_core_get_avatar( get_post_author_id() ); ?>

    @af3

    Participant

    gerikg — this works! thanks!!

    now, if anyone could share how to make sure facebook avatar is showing up in bbpress (using BP-facebook connect) /

    @af3

    Participant

    @gerikg, did u get the fb avatar to show up in bbpress?

    I used the deep integration + extremely crude FB connect integration from newbie’s tutorial that suits me at http://wiki.developers.facebook.com/index.php/Facebook_Connect_Tutorial1

    I then added a filter for bp_core_get_avatar to call the fbconnect_replace_avatar function which was already in the buddypress-fbconnect plugin; of course i put this code as a plugin under my-plugin. Since all my bb profile edit / login re rerouted to bp, i dont really worry abt the extra fbconnect login stuffs. So far, the fb avatar works ok in bbpress in addition to normal user avatar set in bp. If someone could put this as a plugin for bb, would be great.

Viewing 23 replies - 1 through 23 (of 23 total)
  • The topic ‘BP Avatars (and nothing else!) in bbpress… possible?’ is closed to new replies.
Skip to toolbar