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;
}
@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);`
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.
Thanks !!! it worked for me too!!
@mitesh-patel i´m very pleased!!! thanks
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?
@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?
@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;
} ?>