climactivity / netzwerk

Repository zur Wartung und Entwicklung des Netzwerks und dazugehörigen Features.
0 stars 1 forks source link

Show all members of a group #23

Open climates opened 3 years ago

climates commented 3 years ago

when displaying all groups, it should be possible to check out who is already a member of the group.

vovinhd commented 3 years ago

Schlechter Fix in inc/plugins/buddypress-helper.php:162

function group_members( $group_id = false, $role = array() ) {

    if ( ! $group_id ) {
        return '';
    }

    $members = new \BP_Group_Member_Query( array(
        'group_id'       => $group_id,
        'group_role'     => $role,
        'exclude'        => false,
        'search_terms'   => false,
        'type'           => 'active',
    ) );

    $total = $members->total_users;

    $members = array_values( $members->results );

    if( ! empty( $members ) ) {
        ?><span class="bs-group-members"><?php
        foreach( $members as $member ) {
            $avatar = bp_core_fetch_avatar( array(
                'item_id'    => $member->ID,
                'avatar_dir' => 'avatars',
                'object'     => 'user',
                'type'       => 'thumb',
                'html'       => false
            ) );
            ?>
            <img src="<?php echo $avatar; ?>" alt="<?php echo $member->display_name; ?>" class="round" />
            <?php
        }
        ?></span>
        <?php if ( $total - sizeof( $members ) != 0 ) {
            $member_count = $total - sizeof( $members );
            ?>
            <span class="members">
                <span class="members-count-g">+<?php echo $member_count; ?></span> <?php printf( _n( 'member', 'members', $member_count, 'buddyboss-theme' ) ); ?>
            </span>
            <?php
        }
    }

}