Last active
February 3, 2020 12:30
-
-
Save dcavins/71d1a9ee976be6336d67073ddeba5dc6 to your computer and use it in GitHub Desktop.
Filter BP Docs capabilities so that only admins can create new docs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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