Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Change the color of individual role names

@robkk

Moderator

you add this to your themes functions.php or a functionality plugin.

you then use css to style the roles from there.

add_filter('bbp_before_get_reply_author_role_parse_args', 'ntwb_bbpress_reply_css_role' );
function ntwb_bbpress_reply_css_role() {

	$role = strtolower( bbp_get_user_display_role( bbp_get_reply_author_id( $reply_id ) ) );
	$args['class']  = 'bbp-author-role bbp-author-role-' . $role;
	$args['before'] = '';
	$args['after']  = '';

	return $args;
}

add_filter('bbp_before_get_topic_author_role_parse_args', 'ntwb_bbpress_topic_css_role' );
function ntwb_bbpress_topic_css_role() {

	$role = strtolower( bbp_get_user_display_role( bbp_get_topic_author_id( $topic_id ) ) );
	$args['class']  = 'bbp-author-role bbp-author-role-' . $role;
	$args['before'] = '';
	$args['after']  = '';

	return $args;
}

It grabs the topic or reply author role and adds another CSS class with prefix bbp-role- so you now have a new set of CSS classes e.g. bbp-role-keymaster, bbp-role-moderator, bbp-role-participant etc that you can then add your custom CSS styles to.

link this was from

Topic background color depending on role

Skip to toolbar