Skip to:
Content
Pages
Categories
Search
Top
Bottom

Listing groups and (group-related) members on one page for Staff Directory


  • cityfox
    Participant

    @cityfox

    Hi,

    I want to build a staff directory for my company’s Intranet site. I use the Buddypress groups for our departments. I want to have a page that displays all groups and a list of members of a selected group.

    The group names should always be visible on top (like a menu). By clicking on a group (e.g. “Department A”) only members of “Department A” shall be listed under the group names. By clicking on another group (e.g. “Department B”) only members of “Department B” shall be listed under the group names.

    I already found out how to copy and edit the groups-loop.php in my child theme. But I don’t know how to go on.

    I use WordPress 4.2.2 with Buddypress Version 2.3.2.1.

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

  • shanebp
    Moderator

    @shanebp

    Use this function groups_get_group_members.

    Try this somewhere in your groups-loop file:

    $members = groups_get_group_members(); 
    var_dump( $members );

    Handling layout and display is up to you.


    cityfox
    Participant

    @cityfox

    Thanks for the reply. I’m a newbie. I don’t understand what you mean. I put the code with php tags in the groups-loop-file but it doesn’t work correctly. The website shows this:

    array(2) { ["members"]=> array(0) { } ["count"]=> string(1) "0" }

    In the meantime I got another idea: I put the Group Members Loop in the text editor of a wordpress page. I thought if that works I can put the code into a shortcode (with plugin My Shortcodes) and make shortcodes for each group. But the loop doesn’t get the group members. On the website there is the message “This group has no members”. Then I put the group ID into the loop like that:

    bp_group_has_members('group_id=1')

    But still it doesn’t work. I’m lost…


    shanebp
    Moderator

    @shanebp

    Try this:

    $args = array( 
    	'group_id'              => bp_get_group_id(), 
    	'exclude_admins_mods'   => false,
    );
    
    $members = groups_get_group_members( $args ); 
    				
    foreach( $members['members'] as $member ) {
    	echo $member->display_name . '<br/>';
    }
    				
    // for reference, show all the data
    echo '<pre>';
    var_dump( $members );
    echo '</pre>';
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Listing groups and (group-related) members on one page for Staff Directory’ is closed to new replies.
Skip to toolbar