Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show Member List on Group Home


  • N33D
    Participant

    @n33d

    Hi there,

    I’m looking for a solution to show a member list on the group home. But I can’t get any members to show up. I tried a lot, even to copy and paste the legacy /groups/single/members.php file (https://pixelheads.d.pr/xCH6i1) and hooked it on the homepage at the “bp_before_group_body”.

    The custom code works on the “Members” page. It just won’t work on the “Home” of the group page.

    I use the latest WordPress and BuddyPress version. I do not have other plugins installed.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)

  • N33D
    Participant

    @n33d

    A link in this documentation gives a 404: https://codex.buddypress.org/developer/loops-reference/the-group-members-loop-bp_group_has_members/ – see Accepted Parameters – group_id required link to “bp_has_groups() loop”.

    This is my code at the moment:

    
    <?php
        $args = array(
            'group_id' => bp_get_group_id()
        );
    
        if ( bp_group_has_members( $args ) ) : ?>
    
            <ul id="member-list" class="item-list">
                <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
    
                    <li>
                        <span class="avatar">
                            <a href="<?php bp_group_member_domain(); ?>">
                                <?php bp_group_member_avatar_thumb(); ?>
                            </a>
                        </span>
                        <span class="name">
                            <a href="<?php bp_group_member_domain(); ?>">
                                <h4><?php bp_group_member_name(); ?></h4>
                            </a>
                        </span>
                        <span class="actions">
                            <a class="button small" href="<?php bp_group_member_domain(); ?>">
                                <?php esc_html_e('View profile', 'mvp'); ?>
                            </a>
                        </span>
    
                    </li>
    
                <?php endwhile; ?>
    
            </ul>
    
        <?php else: ?>
    
            <div id="message" class="info">
                <p><?php _e( 'No members were found.', 'buddypress' ); ?></p>
            </div>
    
        <?php endif; ?>
    

    Any help appreciated. I’m stuck here.


    N33D
    Participant

    @n33d

    Oh man, was breaking my head about this one for the past days. But found the solution, of course the answer was right there. I forgot to exclude admins and mods in the loop. Don’t understand why they would be excluded in the first place.

    There is the complete code, including to get xProfile fields for anyone that is interested:

    
    <?php
        $args = array(
            'group_id' => bp_get_group_id(),
            'exclude_admins_mods' => false
        );
    
        if ( bp_group_has_members( $args ) ) : ?>
            <ul id="member-list" class="item-list">
                <?php while ( bp_group_members() ) : bp_group_the_member(); ?>
                    
                    <?php $user_id = bp_get_group_member_id(); ?>
                    <li>
                        <span class="avatar">
                            <a href="<?php bp_group_member_domain(); ?>">
                                <?php bp_group_member_avatar_thumb(); ?>
                            </a>
                        </span>
                        <span class="name">
                            <a href="<?php bp_group_member_domain(); ?>">
                                <h4><?php bp_group_member_name(); ?></h4>
                            </a>
                        </span>
                        <span class="platforms">
                            <?php $user_psn_handle = bp_get_profile_field_data('field=PSN handle&user_id='.$user_id); ?>
                            <?php if($user_psn_handle): ?>
                                <i class="icon saturated standalone platform psn"></i>
                            <?php endif; ?>
    
                            <?php $user_xbox_handle = bp_get_profile_field_data('field=XBOX handle&user_id='.$user_id); ?>
                            <?php if($user_xbox_handle): ?>
                                <i class="icon saturated standalone platform xbox"></i>
                            <?php endif; ?>
                        
                        </span>
                        <span class="actions">
                            <a class="button small" href="<?php bp_group_member_domain(); ?>">
                                <?php esc_html_e('View profile', 'mvp'); ?>
                            </a>
                        </span>
    
                    </li>
    
                <?php endwhile; ?>
    
            </ul>
    
        <?php else: ?>
    
            <div id="message" class="info">
                <p><?php _e( 'No members were found.', 'buddypress' ); ?></p>
            </div>
    
        <?php endif; ?>
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar