Skip to content

Instantly share code, notes, and snippets.

@dcavins
Last active February 3, 2020 12:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcavins/71d1a9ee976be6336d67073ddeba5dc6 to your computer and use it in GitHub Desktop.
Save dcavins/71d1a9ee976be6336d67073ddeba5dc6 to your computer and use it in GitHub Desktop.
Filter BP Docs capabilities so that only admins can create new docs.
<?php
function my_docs_create_admins_only( $caps, $cap, $user_id, $args ) {
if ( 'bp_docs_create' == $cap ) {
// Only admins can create docs.
if ( bp_current_user_can( 'bp_moderate' ) ) {
$caps[] = 'exist';
} else {
$caps[] = 'do_not_allow';
}
}
return $caps;
}
add_filter( 'bp_docs_map_meta_caps', 'my_docs_create_admins_only', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment