Support » Plugin: BuddyPress Docs » Limit who can create documents

  • Resolved micster


    Is it possible to limit who can create documents to a specific user level?

    Ideally I would like only Group Owners or Group Moderators to be able to create new documents.

Viewing 3 replies - 1 through 3 (of 3 total)
  • following…

    Plugin Author David Cavins


    Sure. My answer here probably addresses your question:

    In general, we use WP capabilities to see whether a user can do something. You can add filters like this example:

    add_filter( 'map_meta_cap', 'change_who_may_create_docs', 99, 4 );
    function change_who_may_create_docs( $caps, $cap, $user_id, $args ) {
    	if ( 'bp_docs_create' === $cap && {some_logic_for_who_should_be_able_to_create_docs} ) {
    			$caps = array( 'exist' );
    	} else {
    		$caps = array( 'do_not_allow' );
     	return $caps;

    In your example, if you were using vanilla BP Docs, limiting to Group Mods and Admins doesn’t make a lot of sense, since much of Docs happens outside of groups, though you could make up some logic like:

    $is_admin_of_any_group = bp_get_user_groups( $user_id, array(
    		'is_admin' => true,
    	) );
    $is_mod_of_any_group = bp_get_user_groups( $user_id, array(
    		'is_mod' => true,
    	) ); 

    to do a broad check.

    • This reply was modified 10 months, 1 week ago by David Cavins.

    Hey David,

    I see what you mean. I think refusing to save the document unless a group has been selected as you suggested in the other thread ( will achieve what I want.

    It’s a better solution than limiting docs to only admin and moderators. I don’t mind if all the members can create and edit documents, I just don’t want them doing it all willy-nilly wherever they want. I want all the documents contained within the groups.

    Thanks for the help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limit who can create documents’ is closed to new replies.