Skip to:

Can’t give users custom roles.

  • ankylol



    Robin i added the tutor code to my functions file.As you can see in this link –> i can see the role while editing users forum role.But the thing is when i try to give the user that Tutor role and save user profile.The forum role of the user is being -No roles for this forums- so i can’t give the custom role. Also i tried the other custom name functions thing.I created a role and gived it participant perms but couldn’t give that role to user too.

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

  • Robin W


    ok, when I get a moment I’ll take a look



    Thank you, i will be waiting for it.

    Robin W


    ok, I presume you meant this code

    //code to add tutor role 
    function add_new_roles( $bbp_roles )
        /* Add a role called tutor */
        $bbp_roles['bbp_tutor'] = array(
            'name' => 'Tutor',
            'capabilities' => custom_capabilities( 'bbp_tutor' )
        return $bbp_roles;
    add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
    function add_role_caps_filter( $caps, $role )
        /* Only filter for roles we are interested in! */
        if( $role == 'bbp_tutor' )
            $caps = custom_capabilities( $role );
        return $caps;
    add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
    function custom_capabilities( $role )
        switch ( $role )
            /* Capabilities for 'tutor' role */
            case 'bbp_tutor':
                return array(
                    // 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'   => true,
                    // Reply caps
                    'publish_replies'       => true,
                    'edit_replies'          => true,
                    'edit_others_replies'   => false,
                    'delete_replies'        => false,
                    'delete_others_replies' => false,
                    'read_private_replies'  => true,
                    // Topic tag caps
                    'manage_topic_tags'     => false,
                    'edit_topic_tags'       => false,
                    'delete_topic_tags'     => false,
                    'assign_topic_tags'     => true,
            default :
                return $role;

    so with that code loaded to my site, if I go to

    dashboard>users>all users and edit a user, I can change them to the tutor role, and back again and it saves.

    Can you confirm you are using the above code, and that it does not save if you perform the above ?



    Creating a new role
    Select “Roles” from the “Settings” menu at the top of the screen (this menu is only available to space administrators).
    Find a role in the list that is similar to the role you’d like to create, click “…”, and select “Duplicate role”.
    On this new screen you can customize the rules that will apply to users who are assigned this role.



    Hi robin,

    I have the same issue on my site, I added the code as it is but when i give a user the ‘tutor’ role, After saving the role disappears and the user has no bbpress role assigned to them.Even i i signup as a subscriber, If the default role is set to be ‘tutor’ The newly registered user ends up with no bbpress role.


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