Created
November 9, 2017 18:38
-
-
Save dcavins/2884d5b10a365684a37bb50903c044b0 to your computer and use it in GitHub Desktop.
Set the "bp_docs_create" dynamically when in a group.
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 | |
| function my_docs_create_follow_group_associate_setting( $caps, $cap, $user_id, $args ) { | |
| if ( 'bp_docs_create' == $cap && $group_id = bp_get_current_group_id() ) { | |
| // In a group, only set this cap if the user can associate a doc with the group. | |
| if ( current_user_can( 'bp_docs_associate_with_group', $group_id ) ) { | |
| $caps[] = 'exist'; | |
| } else { | |
| $caps[] = 'do_not_allow'; | |
| } | |
| } | |
| return $caps; | |
| } | |
| add_filter( 'bp_docs_map_meta_caps', 'my_docs_create_follow_group_associate_setting', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment