The Stash House (@stashhouse)

Forum Replies Created

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

  • The Stash House
    Participant

    @stashhouse

    PS : it’s the same when I’m trying with your “tutor” code


    The Stash House
    Participant

    @stashhouse

    Hi Robin,

    I have the same issue as 9march using this code in my functions.php :

    /**
     * BBPress : add new role with custom capabilities
     * https://codex.bbpress.org/custom-capabilities/
     */
    
    //code to add "client" role
    
    function add_new_roles( $bbp_roles )
    {
        /* Add a role called tutor */
        $bbp_roles['bbp_client'] = array(
            'name' => 'Client',
            'capabilities' => custom_capabilities( 'bbp_client' )
        );
    
        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_client' )
            $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 'client' role */
            case 'bbp_client':
                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'        => false,
                    'edit_topics'           => false,
                    '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,
                );
    
                break;
    
            default :
                return $role;
        }
    }

    always ending with “-No roles for this forums-” like the new role for the newly registered user was not saved.

    Regards,

    David

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