Skip to:
Content
Pages
Categories
Search
Top
Bottom

Putting the @username below name


  • Tanya
    Participant

    @pjtna

    I am trying to add the username underneath a person’s avatar, like in these forums (circled in the pic above). I know where to add the code in loop-single-reply.php and I have tried looking in the beta release of bbPress 2.3 in case it was included there, but I am not having any luck.

    Would anyone know what code I would need to insert to bring up the username?

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

  • Sambora5150
    Participant

    @sambora5150

    Hi, i think this is the code  i have it from this other topic:

    http://bbpress.org/forums/topic/how-to-display-username-in-bbpress/

     

    i don´t know where tu place it… can anyone help me?

    user = get_userdata( $user_id );
    if ( !empty( $user->user_nicename ) ) {
        $user_nicename = $user->user_nicename;
    }

    Mitesh Patel
    Participant

    @mitesh-patel

    @pjtna and @sambora5150 : Lucky, you guys found me, (or viceversa :) )

    I was looking to do exactly that. So here it is.

    The code should go in bbpress template file loop-single-reply.php, below the PHP code line that contains. The file is located in plugins > bbpress > templates > default > bbpress folder.

    `do_action( ‘bbp_theme_before_reply_author_admin_details’ )`
    Th actual code should be,
    `
    $user = get_userdata( bbp_get_reply_author_id() );
    if ( !empty( $user->user_nicename ) ) {
    $user_nicename = $user->user_nicename;
    echo “@”.$user_nicename;
    }
    `

    But you should never edit that file, as the changes will be lost when you upgrade bbpress plugin.

    So, copy the file and put it in your theme within a folder ‘bbpress’ (you will have to create that folder).

    You will also need to add the following line to your theme’s function.php

    add_theme_support(‘bbpress’);

    OR untested but simple method, add all of the following to the function.php of your theme.

    `function append_mention(){
    $user = get_userdata( bbp_get_reply_author_id() );
    if ( !empty( $user->user_nicename ) ) {
    $user_nicename = $user->user_nicename;
    echo “@”.$user_nicename;
    }
    }

    add_action(bbp_theme_before_reply_author_admin_details, append_mention);`


    Tanya
    Participant

    @pjtna

    Thanks @mitesh-patel, that worked perfectly!

    I was hoping if you could help me out with putting the username on the list of topics page (such as on bbpress.org/support) in the freshness column? Currently, there is just the person’s name.


    Sambora5150
    Participant

    @sambora5150

    Thanks !!! it worked for me too!!

     @mitesh-patel i´m very pleased!!! thanks

     


    redknite
    Participant

    @redknite

    i can’t seem to get this to work… so it’s supposed to look like this?:

    <?php do_action( 'bbp_theme_before_reply_author_details' ); ?>
    $user = get_userdata( bbp_get_reply_author_id() );
    if ( !empty( $user->user_nicename ) ) {
    $user_nicename = $user->user_nicename;
    echo “@”.$user_nicename;
    }
    <?php bbp_reply_author_link( array( 'sep' => '<br />', 'show_role' => true ) ); ?>

    I get a parse error when i do this. What am i doing wrong?


    redknite
    Participant

    @redknite

    can someone please help?


    redknite
    Participant

    @redknite

    @pjtna or @sambora5150 can you tell me how you got this to work? Where did you put the code? and was it exactly like above or did you have to add additional code?


    Tecca
    Participant

    @tecca

    @redknite, put this in your loop-single-reply.php file:

    <?php $user = get_userdata( bbp_get_reply_author_id() );
    if ( !empty( $user->user_nicename ) ) {
    $user_nicename = $user->user_nicename;
    echo "@".$user_nicename;
    } ?>
Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.