Skip to:

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1815 closed task (blessed) (fixed)

Display User role below usernames in replies

Reported by: sooskriszta's profile sooskriszta Owned by:
Milestone: 2.1 Priority: normal
Severity: normal Version: 2.0
Component: Appearance - Included Themes Keywords: dev-feedback has-patch


It is something of a standard feature. I haven't seen many forums without it.

NickMackz has submitted a "patch" at

To loop-single-reply.php add

$reply_user_id = bbp_get_reply_author_id();
global $wp_roles;
$reply_user = new WP_User( $reply_user_id );
$roles = $reply_user->roles;
$role = array_shift($roles);
printf( isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false);

I suggest it be tested and included in 2.1

Attachments (2)

1815.01.diff (8.7 KB) - added by cnorris23 12 years ago.
1815.02.diff (10.7 KB) - added by cnorris23 12 years ago.

Download all attachments as: .zip

Change History (12)

#1 @sadr
12 years ago

I'd say this is plugin territory. There's no one way of doing this. Some want plain text titles, others want image badges, others might integrate Achievements and so forth.

#2 @sooskriszta
12 years ago

  • Keywords has-patch added

Additional functionality like badges and achievements etc may be plugin territory, but the basic functionality of displaying role should really be a part of the core.

#3 @cnorris23
12 years ago

  • Keywords needs-patch added; has-patch removed

I would agree that this should be added, especially since it's part of the standalone bbPress package. However, the patch needs some work, and the addition of some filters. The code also needs to be in the form of a function, and possibly use an action to add it to the template.

#4 @johnjamesjacoby
12 years ago

  • Milestone changed from 2.1 to 2.2

I looked into this in 2.0, and it caused a significant number of additional queries. I agree with cnorris23, and would like us to have an efficient way to make it happen.

Moving to 2.2. If a patch comes through before 2.1 ships, I'm okay squeezing it in.

#5 @cnorris23
12 years ago

  • Keywords has-patch added; needs-patch removed

First draft

I took a different approach than my original comment, but I think this will be easier for majority of users. However, there are still enough filters and individual functions floating around to allow for more control for those so inclined.

@jjj Was about to post the patch when I realized you had posted not long before. Default WP/bbPress install. No effect on query number. WP reported the same number of queries with and without the role being shown.

12 years ago

#6 @NickMackz
12 years ago

Just had a look through your patch. Looks a lot better than mine (obviously). Mine was just a quick fix to do it as I am not really familiar with php as I normally program in Java.

The only thing that I'm not sure about with your patch is whether or not it will work with custom user roles or just the default ones? I use custom roles on my website and forums. The forums are members only so there's no point me posting a link, so here's a screenshot (I've hidden the IPs):

#7 @cnorris23
12 years ago

@NickMackz It will work, but, in it's current form, you'll have to use the filters for custom roles.

#8 @cnorris23
12 years ago

  • Milestone changed from 2.2 to 2.1

New patch. Reworked the switch/case logic so that custom roles are now displayed without having to use filters. Also reworked the actual display of the role. Still not sure it's the best way display the role, but it seems like the best entry place to allow users to gain access to the feature without having to edit custom templates. Plus, as I said earlier, there's enough functions and filters to allow those so inclined to customize as they see fit with little effort.

Moving back to 2.1.

12 years ago

#9 @johnjamesjacoby
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [3860]) Add template tags and supporting functions to display user role in topics and replies. Fixes #1815. Props cnorris23 for original patch.

#10 @johnjamesjacoby
12 years ago

(In [3861]) Default show_role to false, and override to true when needed, for backwards compatibility. See #1815.

Note: See TracTickets for help on using tickets.