Skip to:
Content
Pages
Categories
Search
Top
Bottom

disable assign Topic Tags for non Mods/Keymasters

  • @sysix

    Participant

    Hello Guys,

    I think I have found a bug. But at first some Info from the System:

    WP version 4.8.2
    PHP version 7.0.22-0ubuntu0.16.04.1
    bbPress version 2.5.14-6684

    I want the hide the Tag-Input for all “normal” Users. So only the Keymaster and the mods can assign tags. I found, that I can hook into the capatiblities with bbp_get_caps_for_role and set the settings to false:

    `
    add_filter(‘bbp_get_caps_for_role’, function ($caps, $role) {
    // only the admin can delete and manage topic tags
    if (!in_array($role, [‘bbp_keymaster’])) {
    $caps[‘manage_topic_tags’] = false;
    $caps[‘delete_topic_tags’] = false;
    }

    // only mods and admin can edit or assign tags
    if (!in_array($role, [‘bbp_keymaster’, ‘bbp_moderator’])) {
    $caps[‘edit_topic_tags’] = false;
    $caps[‘assign_topic_tags’] = false;
    }

    return $caps;
    }, 10, 2);

    But the problem is, that in template\defaults\bbpress\form-reply.php we check with:

    <?php if ( bbp_allow_topic_tags() && current_user_can( 'assign_topic_tags' ) ) : ?>

    current_user_can calls WP_User->has_cap and there is $capabilities['assign_topic_tags'] = true.

    —–

    Workaround:

    `
    add_filter(‘user_has_cap’, function($caps, $metaCaps, $args) {
    $forumCaps = bbp_get_caps_for_role($args[0]);

    return array_merge($caps, $forumCaps);
    }, 10, 4);
    `

  • You must be logged in to reply to this topic.
Skip to toolbar