Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add forum roles


  • anallabres
    Participant

    @anallabres

    I have read the whole ‘Roles and Capabilities in bbPress 2.2′ thread but still not sure if there is a way of adding new forum roles.

    I’ve got groups of people answering members questions and I want them to be identified by their expertise (ie. Mentor, Advisor, …) to know how reliable is the answer.

    Is it possible?

    Thanks!

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

  • John James Jacoby
    Keymaster

    @johnjamesjacoby

    • Filter the results of `bbp_get_dynamic_roles()` to add the role.
    • Filter the results of `bbp_get_caps_for_role()` to set the capabilities for that role.

    anallabres
    Participant

    @anallabres

    Thanks for the answer John.

    Just not sure… where should I do that???

    Thanks again!


    graemeviljoen
    Participant

    @graemeviljoen

    Edit the file in wp-content/plugins/bbpress/includes/core

    the file to edit is called capabilities.php


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Edit the file in wp-content/plugins/bbpress/includes/core

    the file to edit is called capabilities.php

    Incorrect; *never* edit any files in bbPress’s directory; you’ll lose those edits when software updates come in.

    @anallabres – Research how WordPress’s actions/filters/plugins work. It’s a little dizzying at first, but a few lines of code can get you up and running.


    Justin Tadlock
    Participant

    @greenshady

    Add new roles with a roles plugin. You don’t have to use code. See: http://wordpress.org/extend/plugins/members


    AzureNinja99
    Participant

    @azureninja99

    @greenshady Doesn’t that plugin make WordPress groups, not BBPress forum roles? I’m trying to do the same thing too.


    blg002
    Participant

    @blg002

    wondering if anyone has a quick snippet of code that answers @anallabres initial question.


    blg002
    Participant

    @blg002

    For posterities sake, i think i figured this out thanks to this article. I was close just had few things I didn’t know about, hopefully I’m not doing anything too terrible.

    
    function add_custom_role( $bbp_roles ) {
      $bbp_roles['my_custom_role'] = array( 
        'name' => 'My Custom User',
        '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 );
    

    janhoos
    Participant

    @janhoos

    Cool! Where did you add that? Did you download a plug-in that lets you create simple plugins? Or did you add that to a functions file somewhere?

    Whats the safest place? Cause I know a few ways of adding this in :P


    blg002
    Participant

    @blg002

    @janhoos i just added it to functions.php

    However, this didn’t end of completely working for me. I would save and the role would not be saved, i believe.


    janhoos
    Participant

    @janhoos

    Hi Blg002,

    It worked for me! Added it to the theme functions and changed the function to add in 3 more roles.

    Can probably optimise it but it works like this right now:

    function add_custom_role( $bbp_roles ) {
    $bbp_roles['my_custom_role'] = array(
    ‘name’ => ‘ACN Lid’,
    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_participant_role() ) // i just want them to have the same capabilities as participants

    );
    $bbp_roles['my_custom_role2'] = array(
    ‘name’ => ‘ACN Aspirant’,
    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_participant_role() ) // i just want them to have the same capabilities as participants

    );
    $bbp_roles['my_custom_role3'] = array(
    ‘name’ => ‘ACN Lid admin’,
    ‘capabilities’ => bbp_get_caps_for_role( bbp_get_keymaster_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 );


    janhoos
    Participant

    @janhoos

    Is there a way to give a custom role a custom set of capabilities?

    Like the ones found on the capabilities.php file?

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

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

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

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

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

    Using the code above, I don’t know where to put the capabilities.

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

You must be logged in to reply to this topic.