Skip to:
Content
Pages
Categories
Search
Top
Bottom

Roles and Capabilities in bbPress 2.2

  • @johnjamesjacoby

    Keymaster

    bbPress 2.2 implements a new way to think about user roles in both WordPress and bbPress. A few users have posted up having issues after upgrading, so I’m going to take some time to explain what changed and why.

    The problem bbPress 2.2 addresses, is the situation where a users ability to take certain actions in the forums was dictated by their role on the entire site, or their “blog role” as I’ll refer to it in some places going forward.

    This means that in the past, a user could not be both a blog Editor and a forum Moderator at the same time; you’d need to be one or the other, and it was clear this wasn’t what anybody wanted.

    In bbPress 2.0 and 2.1, every time you activated bbPress on a site, it went in and added a bunch of capabilities to the database. You never knew this, but it needed these roles so that users could perform certain tasks. bbPress would go in and modify the core WordPress roles, to add these capabilities to them. This made multisite installations a challenge, and network activation was very difficult too, because these roles needed to be added to every single site.

    For existing users of sites, bbPress performed a bunch of calculations and educated guesses to automatically grant users with certain roles and capabilities. To do this, it would eventually need to add capabilities to the user, or switch them to a role that had those capabilities already; Forum Participant.

    Subsequent updates to bbPress required database migration scripts for every change to user roles and capabilities. This is a lot of work for very little gain, since we’re not solving any problems with users needing multiple roles, and at the same time we’re polluting the database with a bunch of data that doesn’t change 99% of the time.

    Under the hood, WordPress comes with support for users having multiple roles, and this is a perfect use-case for needing that functionality. Roles are just groups of capabilities. If a user has a role, it’s safe to assume they also have certain capabilities, right?

    Wrong. Kind of. Sometimes.

    Capabilities are saved in the database, per user, per site, and they bubble based on the role they are granted. If you use any plugin that modifies editable roles or capabilities in the database, what you’re doing is changing the individual capabilities for every user that gets that role going forward, but not necessarily every user that had that role in the past.

    Remember, individual users have individual capabilities. When a user gets a new role that is modified in some way, they also get assigned the changed capabilities, either positive or negative. Negative capabilities are explicitly negative, and neither WordPress nor bbPress use these in core. They’re tricky, and make it easy to break things.

    Once you’ve gone this far in, you’re playing with fire and will likely get burned. You now have altered core user roles, extra forum user roles, and a mish-mash of registered users with a random assortment of capabilities, based on when they signed up, what role they were granted, and what you happened to have changed that blog role’s capabilities to be at that moment.

    To top this all off, there is no “repair” for your users, they’re basically stuck.

    For bbPress users that never modified user roles or capabilities, their update process would be smooth sailing. It’s the modifications to database permissions that cause issues with bbPress 2.2. Why?

    bbPress 2.2 introduces the concept of “dynamic roles” VS WordPress’s “editable roles.” What’s the difference? Editable roles are saved in the database, and allow you to completely shoot yourself in the foot (as above) once you start changing them around. Dynamic roles do not touch the database in any way, other than to assign the 1 role to the user, side-by-side with any other role they might have on your site.

    bbPress comes with filters to allow you to modify the roles, and it’s still possible to add or subtract specific forum capabilities to a user if you needed to, and without all the fuss and danger of bbPress interfering with existing user roles and capabilities.

    For users that are stuck with users that can’t access the forums, try using the forums role repair tool, located in: Admin > Tools > Forums

    That tool loops through your users, and grants them a forum role based on their blog role based on the following map:

    Admin = Keymaster
    Editor = Participant
    Author = Participant
    Contributor = Participant
    Subscriber = Participant

    The map can be filtered, as can the default role of Participant. The problem will come in with existing users that have modified Participant roles that you may have tinkered with. They’ll end up with capabilities that are totally out of whack, no matter what you do. You’ll need to use an additional tool on top of this, if you want to clean up those old roles introduced by plugins like S2member.

    Going forward, I’d like to get a better idea on what these plugins are doing, and make sure that bbPress plays as nicely as it can with them. Dynamic roles in WordPress core are probably a few releases away, but it’s important to bbPress’s future to have them in and working as soon as possible, to get everything dialed in for everyone.

Viewing 25 replies - 26 through 50 (of 73 total)
  • @mouffles

    Participant

    I’ve never used plugins for user roles.
    And i don’t understand anything :

    i can’t promote users as moderators anymore, Moderator roles no longer exist inside wordpress and every wordpress roles wich are not admins can’t moderate forums.

    Then old moderators can’t log in wp-admin to edit bbpress subjects/replies anymore but they can edit replies and topics inside forums…

    What the hell is this mess?? Why wasn’t it said before i upgrade??

    @mouffles

    Participant

    the bad tweak :

    function bbp_filter_blog_editable_roles( $all_roles = array() ) {

    // Loop through bbPress roles
    foreach ( array_keys( bbp_get_dynamic_roles() ) as $bbp_role ) {

    // Loop through WordPress roles
    foreach ( array_keys( $all_roles ) as $wp_role ) {

    // If keys match, unset
    if ( $wp_role == $bbp_role ) {
    //unset( $all_roles[$wp_role] );
    }
    }
    }

    return $all_roles;
    }

    bbpress/core/capabilities/
    And then Moderators are back……. I’m sure i missed something but plugins like “members” don’t do the trick. And i just want basic forum moderation works now.

    I will never understand why endusers have to put their hands in the mess of bbpress and hack/tweak it just to use this plugin >:( I can’t trust in your plugin every updates are hell.

    Then, don’t work as a dirty pig, and update the doc when you change such important things like roles! It just a little more repectfull for end users.

    @gdragon

    Participant

    When creating new user, bbPress role is not added. I don’t have any roles plugins or anything like that. I create new Subscriber user, and it doesn’t get bbPress role. I am using bbPress 2.2.3. Is there something needed to make this work, or should it work automatically?

    EDIT: OK, there is a setting to allow this, and it is disabled by default for some reason.

    EDIT 2: And no luck, even with this option ON, roles are still not assigned to new users.

    @johnjamesjacoby

    Keymaster

    If you create the user, it doesn’t assign them a role right away. They’ll get role mapped once they login to the site, or once you assign them a role.

    @gdragon

    Participant

    OK, thanks!

    @mcfly83

    Participant

    After upgrading to 2.2.x all users got access to private forums, even those without any assigned (forum) role. How can I fix that? I’m totaly stuck.

    See also here: https://bbpress.org/forums/topic/2-2-permissions-and-404-problems/#post-121248

    @anallabres

    Participant

    Sorry but I am completly lost with all it’s said.

    My question is: Is there any way to add new roles in bbpress?

    I want some of my users to be identified by their knowledge so the mebers know who is responding and the accuracy of the info provided (ie. Mentor, Advisor, …).

    From the first message in this post

    bbPress comes with filters to allow you to modify the roles, and it’s still possible to add or subtract specific forum capabilities to a user if you needed to, and without all the fuss and danger of bbPress interfering with existing user roles and capabilities.

    I understand it is possible to add new roles but can not find how to do it!

    I am using BBpress 2.2.2 and WordPress 3.4.2

    Thanks!!

    @aburi

    Participant

    John, and people like Justin – thanks for all your hard work.

    @erwinodendaal

    Participant

    I guess my problem that subscribers/forum participants after the update of bbPress 2.2 can no longer edit their profile page (and all subscribers/participants before could) are a result of the incompatibility of bbPress and the Members plugin?
    Do I still need the Members plugin now that the roles for WordPress and bbPress are no longer one?

    @rigormortis_uk

    Participant

    so if:

    Admin = Keymaster
    Editor = Participant
    Author = Participant
    Contributor = Participant
    Subscriber = Participant

    Then which role do we assign to make someone a forum moderator??

    @johnjamesjacoby

    Keymaster

    @rigormortis_uk – The Moderator role.

    Users can have multiple roles; in this case one for the site, and one specifically for the forums.

    @webheadllc

    Participant

    Would I be able to have a user that is an Editor be able to create forums? I made this user a Keymaster, but it looks like I have to grant the user the ‘manage_options’ capability to get the Forums menu item to show. Is there another way? Thanks.

    @johnjamesjacoby

    Keymaster

    @webheadllc – That’s a bit of an oversight on my part. The ‘manage_options’ capability was an easy check originally, and you’re right that Key Masters should be able to create forums. I’ll make sure it’s fixed in 2.3.

    Update: Fixed in trunk.

    @webheadllc

    Participant

    Sweet! Thanks!

    @marjoriesdaughter

    Participant

    This is a great discussion, and thanks for the fantastic post, John!
    I have a client who has a 3.4.1 multisite install with custom users roles. She wants certain of her users, who aren’t admins, to be able to (Condition 1) moderate their new bbPress forums – 2.1.3. But, she doesn’t want them to even be able to (Condition 2) even see the other plugins in the Dashboard. I’m concerned about using manage_options because I don’t know whether it would fulfill condition #1. What is the best way to set this up?

    @netweb

    Keymaster

    I have updated the codex docs for bbPress User Roles and Capabilities introduced with 2.2.


    @MarjoriesDaughter
    I would suggest you update bbPress to the latest 2.2.3 version rather than use an old version, with that then both your conditions above will be met.

    @amy-joy

    Participant

    I did this:

    For users that are stuck with users that can’t access the forums, try using the forums role repair tool, located in: Admin > Tools > Forums

    yet some of my users still don’t have access to the forums when they are logged in. I run a multisite with buddypress and no additional membership plugins. I’m not sure what to try next. Any suggestions?

    @latas

    Participant

    For all users who couldn’t fix the issue that basic users can not reply or create a new topic, I found at least where is my problem.

    It is located in the functions.php file in the line 216. This is for the version 2.2.3. I’m using bbpress as plugin in WordPress 3.5.

    File located at bbpress plugin folder -> includes/replies/functions.php

    The code that does not allow me to post as a Participant is this:
    if ( !bbp_check_for_blacklist( $anonymous_data, $reply_author, $reply_title, $reply_content ) )
    bbp_add_error( ‘bbp_reply_blacklist’, __( ‘ERROR: Your reply cannot be created at this time.’, ‘bbpress’ ) );

    So it looks some blacklist check is working on. And the question is, where in the setup of WordPress, is located the blacklisted information, to verify why this is happening.

    By the way, if that function only does what it looks to do by its name, I commented it.
    Everything works now.

    Can you give me further info about this?

    Thanks.

    @benracicot

    Participant

    Oh man what a post:
    I agree that I don’t want to use a plugin to add a capability to my custom role. I use a snippet to add capabilities to my “Master Editor” role.

    However, there doesn’t seem to be a capability to get these roles to be able to use the “Forum”, “Topics” and “Replies” tabs.

    Are there any solutions floating around to add BBPress caps to users?

    @sssstrick

    Participant

    @johnjamesjacoby Aside and onto the topic of “Forum Roles”. Is there a way we can add more custom roles?

    @noumaan

    Participant

    I read this entire thread and I am still unclear about this. On my site, I am trying to make a user Keymaster. The user’s WordPress role is subscriber and I want them to have the forum role of the keymaster. The problem is that the user can not see Forums menu item on their dashboard and can not perform keymaster actions. So how do we make someone a keymaster without giving them access to administration of the whole site?

    @netweb

    Keymaster

    @noumaan I just tested this and everything works as expected with a WordPress user with the WP role ‘Subscriber’ and bbPress role ‘Keymaster’
    These following are the only admin panels available/visible in the WP admin dashboard:

    • Home – Right now in forums (stats)
    • bbPress Forums, Topics and Replies panels
    • Profile (Edit own profile)
    • Tools -> Forums (Repair, Import & Reset bbPress tools)
    • Settings -> Forums (Main bbPress settings)

    @nubc

    Participant

    I am still having issues trying to allow my regular subscribers to have access to the forums. They can see the members section and the other parts but anything associated with the forums doesn’t work. I do not want to give them admin privileges. I have tried the repair suggested by Amy Joy. I don’t know what else to do as this is a MAJOR part of my site. Any suggestions?

    Tammy
    http://www.nookusersbookclub.com

    @anickers

    Participant

    Hello John and Jame

    Hello Stephen Edgar

    I want you to reply my query because I am the kind of guy who always go by logic and I am not able to find any logic how to resolve my issue. I know this is not proper thread to ask but I waited 2 days before I could post in this bbpress forum since they always deleted my post before now. In case I have only one topic in my profile so I am avoiding to write url in this thread not to disturb you guys 🙂

    @nubc

    Participant

    So I found a fix for my error. I downloaded the user role editor and found that all of my permissions had been changed for the subscriber. Changed them back to allow forum access and it’s been working just as before.

Viewing 25 replies - 26 through 50 (of 73 total)
  • You must be logged in to reply to this topic.
Skip to toolbar