-
-
Save willguesser/c84b89e7ceb40b44e31c8d1d87eebdf2 to your computer and use it in GitHub Desktop.
Only allow certain users to create docs.
This file contains hidden or 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 | |
add_filter( 'bp_docs_map_meta_caps', function( $caps, $cap, $user_id, $args ) { | |
if ( 'bp_docs_create' === $cap ) { | |
// Site admins | |
if ( user_can( $user_id, 'bp_moderate' ) ) { | |
$caps = array( 'exist' ); | |
// If this is a group and the user is a group mod or admin. | |
} else if ( bp_is_group() && ( bp_group_is_mod() || bp_group_is_admin() ) ) { | |
$caps = array( 'exist' ); | |
} else { | |
$caps = array( 'do_not_allow' ); | |
} | |
} | |
return $caps; | |
}, 20, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment