• Resolved Achim

    (@ar7)


    Is it possible to set a minimum role for creating ANY docs?

    Thank you, kind regards,

    Achim

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author David Cavins

    (@dcavins)

    Hi a.r.7-

    BP Docs has a variety of permissions that are calculated using WordPress’s user_can() system. For instance, who can create a doc is checked via current_user_can( 'bp_docs_create' ). (You can see the logic in includes/caps.php.) The important filter you need to change the default capabilities is bp_docs_map_meta_caps. The following example restricts doc creation to users that are editors (WP Role) or higher:

    
    add_filter( 'bp_docs_map_meta_caps', 'my_bpd_disallow_some_creators', 10, 4 );
    function my_bpd_disallow_some_creators( $caps, $cap, $user_id, $args ) {
    
        if ( 'bp_docs_create' == $cap ) {
            // For example, only users with the WP editor role caps can create docs.
            if ( ! current_user_can( 'delete_others_pages' ) ) {
                $caps[] = 'do_not_allow';
            } else {
                $caps[] = 'exist';
            }
        }
    
        return $caps;
    }
    
    Thread Starter Achim

    (@ar7)

    Thank you, this works fine for me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Minimum role for creating ANY docs?’ is closed to new replies.