Skip to:
Content
Pages
Categories
Search
Top
Bottom

username function


  • Arturo
    Participant

    @arturo84

    hi, what’s the function to have the username with bbpress? post_author() show the name and not the username.

    for example, my username is arturo84, but with the post i see Arturo, so i want the function for the username.

    thanks for the help.

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

  • Tom(dB)
    Participant

    @tomdebruin

    Have a look at bb-includes/functions.bb-template.php you’ll see the functions function get_post_author( $post_id = 0 ) and function post_author_link( $post_id = 0 ).

    You’ll need to recreate those in a plugin or in your functions file to use $user->user_login instead of $user->display_name.

    Have a look at profile.php in your theme to see how it is generated there. But remember that on post.php you’ll have to pass in the ID of the post to get the username otherwise you’ll be fetching details on the logged in user rather post author.

    I hope that helps, good luck.

    An easier way would be to take away the ability to allow change of display name. Then it will default to username anyway. Have a look at topic/help-with-basic-command-to-add-new-profile-fields if that’s the avenue you want to take. If you do, don’t forget to set everyones ‘nicename’ back to what their username is.


    Arturo
    Participant

    @arturo84

    in profile.php i’ve found this <?php echo get_user_name( $user->ID ); ?> but in post.php don’t print nothing… i don’t know bbpress very good to recreate the function :(

    any idea for a simplest way?

    thanks!


    Ben L.
    Member

    @nightgunner5

    <?php
    $user = bb_get_user( get_post_author_id() );
    echo $user->user_login;
    ?>


    Arturo
    Participant

    @arturo84

    u”re the best! thanks Ben!


    Tom(dB)
    Participant

    @tomdebruin

    oh yeah. Doh! Cheers, Ben L.

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

You must be logged in to reply to this topic.