Skip to:

Show number of friends within members loop bp_the_site_member_total_friend_count

  • thomasbp


    I’m trying to display the number of friends a user has within the members loop.

    I found this function “bp_the_site_member_total_friend_count()” which appears to be the appropriate way (at least it’s listed next to other members loop functions ). However, it doesn’t output anything.

    Do I have to pass an argument while calling that function (ID of the user didn’t work) or what am I doing wrong?

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

  • buzz2050


    No, this function does not take any parameters from what I know. It is supposed to work as is. But it doesn’t in my case either. Not sure why.

    This is the workaround that I am using in my members-loop which does seem to work:

    ‘global $site_members_template ;

    $frndCnt = friends_get_friend_count_for_user($site_members_template->member->id) ;

    echo $frndCnt ;’


    As long as you are doing this from within the bp_has_site_members() loop (and not the friends loop or something by accident), it should work. Have a look at the usage in theme/directories/members/index.php



    I’m late, but thx u2!

    @DPaul: I’ve used that template while I was desparately looking for a solution. However, I probebly miss something obvious.

    @buzz2050: Your workaround did it!



    It works for me BUT
    I am trying to get the total users for each user not the one logged in. I want to show popular members (which I have) with the total friends each has. Don’t know code well enough, anyone know how? I assume it is a little like Buzz2050 workaround.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show number of friends within members loop bp_the_site_member_total_friend_count’ is closed to new replies.
Skip to toolbar