Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcavins/0d4750c54847afd1d92fa34e34539f45 to your computer and use it in GitHub Desktop.
Save dcavins/0d4750c54847afd1d92fa34e34539f45 to your computer and use it in GitHub Desktop.
BP Docs: Don't allow group docs to have "creator only" access
<?php
add_filter( 'bp_docs_get_access_options', 'remove_creator_option_for_group_docs', 10, 4 );
function remove_creator_option_for_group_docs( $options, $settings_field, $doc_id = 0, $group_id = 0 ) {
if ( ! $group_id ) {
$group_id = bp_docs_get_associated_group_id( $doc_id );
}
// If this is the Doc creation page, check to see whether a
// group id has been passed somewhere
if ( empty( $group_id ) ) {
if ( isset( $_POST['associated_group_id'] ) ) {
$group_id = intval( $_POST['associated_group_id'] );
} else if ( isset( $_GET['associated_group_id'] ) ) {
$group_id = intval( $_GET['associated_group_id'] );
} else if ( isset( $_GET['group'] ) ) {
$maybe_group = BP_Groups_Group::get_id_from_slug( $_GET['group'] );
if ( $maybe_group ) {
$group_id = $maybe_group;
}
}
}
if ( $group_id && current_user_can( 'bp_docs_associate_with_group', $group_id ) ) {
foreach ( $options as $key => $opt ) {
if ( 'creator' === $opt['name'] ) {
unset( $options[ $key ] );
}
}
}
return $options;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment