Skip to content

Commit

Permalink
Hide 'Add New File' elements for non-group-members.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Jul 20, 2024
1 parent 9ec3d1a commit 514417e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 7 additions & 5 deletions buddypress/groups/single/documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,13 @@ function ( $folder ) {
<?php esc_html_e( 'No files have been added yet. Add a new file below.', 'commons-in-a-box' ); ?>
</p>

<div class="upload-new-file">
<?php if ( 'add' === $template->operation ) { ?>
<a class="btn btn-primary link-btn" id="bp-group-documents-upload-button" href="" style="display:none;"><?php esc_html_e( 'Add new file', 'commons-in-a-box' ); ?></a>
<?php } ?>
</div>
<?php if ( $user_can_upload ) : ?>
<div class="upload-new-file">
<?php if ( 'add' === $template->operation ) { ?>
<a class="btn btn-primary link-btn" id="bp-group-documents-upload-button" href="" style="display:none;"><?php esc_html_e( 'Add new file', 'commons-in-a-box' ); ?></a>
<?php } ?>
</div>
<?php endif; ?>
</div>

<?php endif; ?>
Expand Down
7 changes: 5 additions & 2 deletions lib/menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,13 @@ function openlab_group_files_submenu() {
$current_item = $base_url;

$menu_list = [
$base_url => __( 'All Files', 'commons-in-a-box' ),
$base_url . '?action=add_new_file' => __( 'Add New File', 'commons-in-a-box' ),
$base_url => __( 'All Files', 'commons-in-a-box' ),
];

if ( current_user_can( 'bp_moderate' ) || groups_is_user_member( bp_loggedin_user_id(), groups_get_current_group()->id ) ) {
$menu_list[ $base_url . '?action=add_new_file' ] = __( 'Add New File', 'commons-in-a-box' );
}

return openlab_submenu_gen( $menu_list, false, $current_item );
}

Expand Down

0 comments on commit 514417e

Please sign in to comment.