Quantcast
Channel: SEM Truth
Viewing all articles
Browse latest Browse all 10

bbPress 2.0 (plugin) – Adding User Role to Replies

0
0

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:

$user_id = bbp_get_reply_author_id();

$user = new WP_User( $user_id );

if ( !empty( $user->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;
}
}

?>


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images