Last active
February 3, 2020 12:22
-
-
Save dcavins/2f185a4023a67a9506a68fcd328de61c 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