Skip to:
Content
Pages
Categories
Search
Top
Bottom

BBpress "post_author_link" problem?


  • Korhan Ekinci
    Participant

    @korhanekinci

    Using 1.0.3 bp, wpmu 2.8.1 and 1.0.1 bbpress.

    I have deep integration bbpress and bp and all working ok. Just realized today that there are problems with forum “post_author_links”:

    http://fenerbook.com/forum/topic/fenerbahcenin-transfer-gundemi-alev-alev#post-33

    username is “nbsmrt” and his name is “murat” and his member page is at:

    http://fenerbook.com/members/nbsmrt/

    I am confused here, maybe lack of sleep past 10 days! As you see in the forum page below the avatars are “names” of the people and linked to their member page through usernames, then why is this one has no link and his username is displayed instead of his name linked to member page through username???

    post.php of bbpress is

    <p>

    <?php post_author_link(); ?>

    <small><?php post_author_title(); ?></small>

    </p>

Viewing 2 replies - 1 through 2 (of 2 total)

  • Greg
    Participant

    @rebootnow

    The thing is that bbPress doesn’t know that the user “nbsmrt” has BP Name “murat”.

    UPDATE: Scratch that – your display names should actually be working, and in fact I see that they are for users other than “nbsmrt”. The bit I put below is necessary if you want the author link to go back to their BP profile instead of the bbPress profile page.

    I wanted the name to be consistent everywhere, so I have a bit of common code that displays the user’s details in forum posts, blog comments, etc. Note that it requires deep integration because I am accessing BP variables inside bbPress.

    For example, here is what I do in the forum…

    First, in post.php I get the author’s details like so:

    $author_id = get_post_author_id( $post_id );
    $author = get_userdata( $author_id );
    $author_loginname = $author->user_login;
    $author_displayname = get_post_author();

    Then I call a function to display the user link, avatar and other things. Part of this function does the following:

    <?php
    $author_url = _profile_url( $author_loginname );
    ?>

    <div class="username">
    <a href="<?php echo $author_url ?>"><?php echo $author_displayname ?></a>
    </div>

    And here is the code for the _profile_url() function:

    function _profile_url( $login_name=0 ) {
    global $bp;

    /* if no login name is specified, use logged in user */
    if ($login_name) {
    $url = $bp->root_domain . '/members/' . $login_name . '/profile';
    } else {
    $url = $bp->loggedin_user->domain . 'profile';
    }

    return $url;
    }

    So the user’s BP Name is always used, and it always links to their BP profile.

    My one concern about all this is that get_userdata() does a SQL query, adding one query for each author in a topic thread.


    Korhan Ekinci
    Participant

    @korhanekinci

    Thank you sooooo muchhh Reboot Now!

    One thing is that, still I have “nbsmrt” (username and not the name) linking to his profile (which is perfect) after your coding. How can it be solved that the name “murat” is shown and not the username.

    http://fenerbook.com/forum/topic/fenerbahcenin-transfer-gundemi-alev-alev

    Thanks again for the help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘BBpress "post_author_link" problem?’ is closed to new replies.
Skip to toolbar