bbPress: Rename Forum Roles
Changes the names of bbPress forum roles shown next to members' posts, for example "Participant" to "Member" and "Keymaster" to "Admin".
Opens WPIDE on
Code
if ( ! function_exists( 'bbp_get_dynamic_roles' ) ) {
return;
}
// bbPress role => new name.
$wpide_bbp_role_names = array(
'bbp_keymaster' => 'Admin',
'bbp_moderator' => 'Moderator',
'bbp_participant' => 'Member',
'bbp_spectator' => 'Reader',
);
add_filter( 'bbp_get_dynamic_roles', function ( $roles ) use ( $wpide_bbp_role_names ) {
foreach ( $wpide_bbp_role_names as $role => $name ) {
if ( isset( $roles[ $role ] ) ) {
$roles[ $role ]['name'] = $name;
}
}
return $roles;
} );
Notes
Only the labels change; capabilities stay the same.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.