Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get group user ids from while loop


  • handyandywilson
    Participant

    @handyandywilson

    Hey guys, I’m looking to display all user ids of members in a specific group to be displayed on any page of my site. This is what I have at the moment…

    add_shortcode ('members', 'members_func');
    function members_func(){
    global $bp;
    $group = 1;
    $users = array();
    if ( bp_group_has_members('group_id='.$group.'') ){
    while ( bp_group_members() ) : bp_group_the_member();
    $user = bp_group_member_id();
    array_push($users, $user);
    endwhile;
    }
    print_r($users);
    }

    … If I echo bp_group_member_id in the loop it works perfectly however when I try to save these values in an array and print_r it I am just getting an array with no values…

    [0] => [1] => [2] =>

    Any ideas on how I can output this? Can this be achieve with a foreach loop for example?

    Thanks for any help in advance 🙂

    Andy

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get group user ids from while loop’ is closed to new replies.
Skip to toolbar