Skip to:
Content
Pages
Categories
Search
Top
Bottom

Weird behaviour modifying bbp_get_caps_for_role() in core/capabilities.php


  • moonoi
    Participant

    @moonoi

    I have a few questions that I was hoping one of the bbPress developers would be able to give me a quick hint about offhand.

    I’m getting results that leave me completely puzzled, as I try to hook into or directly modify the `bbp_get_caps_for_role()` function in `/core/capabilities.php`.

    The `bbp_get_caps_for_role` filter
    My purpose is to try and return an array with true on all caps for any role, because I need to find out why only the keymaster gets to upload images.

    My first attempt is just to use the `’bbp_get_caps_for_role’` filter provided by the function. This is where the mysterious stuff starts…

    I can add the filter, and when I check the `$wp_filters` global afterwards, I can verify that the filter has been added correctly. However it doesn’t fire. When I check the `$wp_filters` array inside the `bbp_get_caps_for_role()` function, just before the hook is applied, my filter has vanished. So somewhere there must be a function removing my filter. But where, and why!?

    Testing by returning the `$caps` array with all caps set to `true`
    So giving up on the filter for now, I simply try to hardcode the all-true `$caps` array directly into the `bbp_get_caps_for_role()` function and returns this, regardless of role. What then happens is even weirder. – Now my user can not even post a reply in the forum.

    How can setting all caps to true end up giving my user less rights in the forum?!

    Thanks in advance guys!

    For reference, here is the bottom part of my hacked `bbp_get_caps_for_role()` function:
    `

    ‘assign_topic_tags’ => true,
    );

    break;
    }

    $caps = array(

    // Keymasters only
    //’keep_gate’ => true,

    // Primary caps
    ‘spectate’ => true,
    ‘participate’ => true,
    ‘moderate’ => true,
    ‘throttle’ => true,
    ‘view_trash’ => true,

    // Forum caps
    ‘publish_forums’ => true,
    ‘edit_forums’ => true,
    ‘edit_others_forums’ => true,
    ‘delete_forums’ => true,
    ‘delete_others_forums’ => true,
    ‘read_private_forums’ => true,
    ‘read_hidden_forums’ => true,

    // Topic caps
    ‘publish_topics’ => true,
    ‘edit_topics’ => true,
    ‘edit_others_topics’ => true,
    ‘delete_topics’ => true,
    ‘delete_others_topics’ => true,
    ‘read_private_topics’ => true,

    // Reply caps
    ‘publish_replies’ => true,
    ‘edit_replies’ => true,
    ‘edit_others_replies’ => true,
    ‘delete_replies’ => true,
    ‘delete_others_replies’ => true,
    ‘read_private_replies’ => true,

    // Topic tag caps
    ‘manage_topic_tags’ => true,
    ‘edit_topic_tags’ => true,
    ‘delete_topic_tags’ => true,
    ‘assign_topic_tags’ => true
    );

    return $caps;
    //return apply_filters( ‘bbp_get_caps_for_role’, $caps, $role );
    }
    `

Viewing 3 replies - 1 through 3 (of 3 total)

  • moonoi
    Participant

    @moonoi

    Just bumpin’


    moonoi
    Participant

    @moonoi

    Found out that the setting causing the whole post form to disappear, following my hack to the `bbp_get_caps_for_role()` function, was `’moderate’ => true,`. Setting this to false makes the post form available.

    However, still no way to upload pictures for non-keymasters.

    Hope one of the bbp core coders have a tip for this one.


    moonoi
    Participant

    @moonoi

    So I found the solution for this. Created a new thread:

    [SOLVED] Only keymasters (admin) can upload images

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar