Skip to:

bbpress info in wordpress?

  • How do I insert info from bbpress into wordpress? I would like to insert the “edit profile” link and some other stuff into my wordpress sidebar.


Viewing 23 replies - 1 through 23 (of 23 total)
  • Those two plugins don’t help at all. Basically if you have a lil php code that you have in your bbpress theme to display anything from display names, profile info or the avatar when using upload avatar plugin….when you paste that code on the wordpress side you get an error.

    Yeah. That’s because WP doesn’t load bb and all the associated functions. You have two options: you could set up wp to always load bb, or you could recreate the functionality yourself. The first could be tricky and fiddly, the latter means coding the PHP yourself. We can help with either.

    I would appreciate any help. Whichever is the easiest and will work the best. I’m fairly new to coding myself, but I learn fast. is where I’m doing this. I have a lil login form in that first box in the sidebar and once you login, it has a couple links now, like logout. I would like to be able to show the user’s avatar with the “upload avatar” plugin, the private message link(s) from the “private message” plugin.

    Thanks for the help!


    “I would like to insert the “edit profile” link and some other stuff into my wordpress sidebar.”

    -> I think we have solved this question in the other topic ;-)

    Okay, but which do you want to do? I don’t feel qualified to make that decision for you. Can you make a start on either?

    the edit profile link, yes, that was resolved, but I just meant that statement as an example. There are other things from bbpress that I would like to have displayed in my wordpress sidebar.

    Well, since you mentioned that the first option can be tricky, lets start with the latter? the php code?



    Didn’t see ganzua’s post, posted at the same time. 😮

    When copy and pasting the code you have to remove any bb dependencies. For example, bb uses the $bbdb; wordpress uses the $wpdb, and for queries and the like you can just switch them. Note that $wpdb does not contain information about the names of bb tables, so $wpdb->topics or the like will not work. In other cases the function names are simply different; bb_get_option() or simply get_option() for example. This code is what I used in bbSync to integrate avatars:

    function bbreplyavatar() {
    global $bbposter, $opshuns;
    $avatar = get_usermeta( $bbposter->ID, 'avatar_file' );
    $avatar = explode('|', $avatar );
    $bburl = $opshuns['bburl'];
    echo '<img alt="' . $bbposter->user_login . ' avatar" src="' . $bburl . '/avatars/' . $avatar[0] .'" class="avatar" />';

    Note that $opshuns and $bbposter need definition (or changing). bbSync could be quite useful to you actually.

    What’s the specific problem you want to solve right now, and what have you tried?

    I wouldn’t know where or how to insert something like you posted above. I thought that since both wordpress and bbpress were using the same database that all I’d have to do is paste the code. Like this for the avatar plugin I am using in bbpress:

    <?php avatarupload_display($user->ID); ?>

    Same database but not same codebase. However you can make bb load wp at the start, and you can make wp load bb at the start (that’s the other method). It’s not difficult but not guaranteed to work, because only a few people have done it. It might mean fiddling with things until they work. If you did that, you could do what you were trying.

    Plugin Name: WP Avatars

    function wp_aud( $felID ) {
    $avatar = get_usermeta( $felID, 'avatar_file' );
    $avatar = explode('|', $avatar );
    $bburl = 'Plz enter the URL of your bb install here';
    echo '<img alt="' . $bbposter->user_login . ' avatar" src="' . $bburl . '/avatars/' . $avatar[0] .'" class="avatar" />';

    Otherwise you could paste that in a new text file, save it in your plugins folder, activate it and then use this in wordpress:

    <?php wp_aud( $comment->user_ID ); ?>

    In theory.

    I’m confused… I activated that plugin and pasted what you put…but all that is there is the the word “avatar”…. :(

    I put in the url of the forum… did I do something wrong?



    The URL doesn’t point to a valid image file so it just displays the alt text. Check what’s wrong with the URL (and remove the pointless reference to $bbposter->user_login).

    well, this plugin names the images by username I think. It also has a default image if no avatar has been uploaded… shouldn’t there be some sort of code there to reference a person’s username?

    $avatar[0] is the filename I believe. Have you checked what’s wrong with the urls?

    I don’t know the php code. I followed what was stated above. The URI points to the right folder. When you upload an avatar using the bbpress upload avatar plugin, it renames the image you upload to your username.

    Forget about the PHP.

    Where it just says “avatar” instead of displaying the image, open the page source (in FF: Ctrl + U, in IE: probably something), then search for “avatar” until you hit the right place. There should be an image tag. Look at the src property. Does that URL point to a valid image file? If not, what does it read?

    It is pointing to the correct folder, just isn’t pointing to any file like it should.

    Ok, so I’ve figured out some more info to share…

    First, the code posted above needs to reference the file type (.jpg, .jpeg, .gif, or .png). Right now the code only points to the avatars folder.

    Next, I’ve figured out that the “avatar upload” plugin for bbpress does rename the images to the user’s username, but makes it all lowercase letters if there are any caps.

    Hope that helps.

    Thank you!!

    by looking at the code for the “upload avatar” plugin I found this…


    This is what I have now, but nothing displays for the filename, just



    Plugin Name: WP Avatars


    function wp_aud( $felID ) {

    $avatar = strtolower($user->user_identity);

    $bburl = ‘;;

    echo ‘<img alt=”avatar” src=”‘ . $bburl . ‘/avatars/’ . $avatar . ‘.jpg” class=”avatar” />’;



    I got to thinking… being that it renames the image to their usernames, I thought that the following might work, but it doesn’t…

    <img src=”;?php echo $strtolower($user->user_identity); ?>.jpg” alt=”avatar” />

    Shouldn’t that work? I’m trying to get it to display the current username of the person visiting the site, provided they are logged in. If they aren’t logged in it shouldn’t display anything. Later I’d like to figure out how to do an if else statement so that if the visitor isn’t logged it, it will display a default image.

    YAY!!! I figured it out!

    <?php global $user_identity;


    if ($user_identity == ”) {

    echo(‘Welcome Guest’);

    } else {

    echo(‘<img src=”/forum/avatars/’ . strtolower($user_identity) . ‘.jpg” alt=”avatar” />’);





    an update…

    I didn’t know until I tried, but you can leave that .jpg out and it will load any image file that matches that query.

    Kahil, your method works well if your users use their login name as their display name. However if a user who’s login is user23 changes his display name to John Doe then your code looks for this image. /forum/avatars/John Doe.jpg instead of the correct avatar image which would be /forum/avatars/user23.jpg. I couldn’t figure out a clean way to fix this (I’m using wpmu, not wordpress). But here’s a dirty hack.

    $comment_author_dn = get_comment_author();
    $comment_author = $wpdb->get_row("SELECT <code>user_login</code> FROM <code>wp_users</code> WHERE <code>display_name</code> = '$comment_author_dn'");
    echo '<img id="comment-avatar" height="50" width="50" src="/forums/avatars/' . (empty($comment_author->user_login) ? "default" : $comment_author->user_login) . '" alt="avatar" />';

    That code should find images for a user if they use a display name or not.


    I haven’t fully tested it, but it seems to work ok.

Viewing 23 replies - 1 through 23 (of 23 total)
  • You must be logged in to reply to this topic.
Skip to toolbar