bbPress 2.0 (plugin) – Adding User Role to Replies

In bbPress 2.0, the recent plugin version, that comes packed with the twentyten bbPress theme, I noticed that a role was not being displayed within the topic reply template.

I ended up adapting the core design from twentyten to WooThemes Canvas and felt the forum role was an essential aspect that was missing.

I came up with a quick solution but perhaps you can contribute a more dynamic solution for removing the bbp_ prefix that is included when simply displaying a bbPress Role.

Here is what I came up with:

roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role )
if ( $role == bbp_moderator ) {
echo 'Moderator';
} elseif ( $role == bbp_participant ) {
echo 'Participant';
} else {
echo $role;