[Tutorial] How to add custom roles to bbPress

The default bbPress Roles are Keymaster, Moderator, Participant, Spectator, and Blocked. However, there is no option to rename these roles. For this tutorial, we will be adding a custom role called “Developer” that we want to have the same capabilities as the participant rank, which is the default rank.

  1. Navigate to your site’s public_html/wp-content/themes/(theme name)
  2. Open functions.php
  3. The first line, which is <?php , should not be edited.
  4. On the next line, paste this code:
function add_custom_role( $bbp_roles ) {
 $bbp_roles['developer'] = array( 
 'name' => 'Developer',
 'capabilities' => bbp_get_caps_for_role( bbp_get_participant_role() ) // i just want them to have the same capabilities as participants
 );

 return $bbp_roles;
} 
add_filter( 'bbp_get_dynamic_roles', 'add_custom_role', 1 );
  1. If you want to change the name of your role, just edit the code above from developer to whatever you want your role to be before saving the functions.php file.
  2. As long as your theme doesn’t update, these roles will work. If you know how to use child themes in WordPress, that would be a much better solution, but it is up to you.
About the author

Timtech

The site admin :)

Readers Comments (2)

  1. first of all thank you for this post it was really helpful to start with custom user type in wordpress. But I want to use new registration form in my website and add the role of custom created user to that registration how can I achieve this ? any help will be appreciated. thank you !

    • These are custom bbPress roles, not custom general WP roles. However, in bbPress settings you should be able to assign a default bbPress role to users that do not have one. The custom bbPress role should be assignable within this menu.

Leave a comment

Your email address will not be published.


*