Skip to:

user_id in code for custom members loop

  • I’m creating a custom members loop to show a few active members. I pass query args to bp_has_members(), then include the usual members loop.

    Some member info is displayed correctly, e.g. bp_group_member_link() does show the member’s name, linked. But the link is missing. Also, the avatar isn’t showing.

    I’ve drilled down into the core functions and by dumping the global $members_template that’s used I can see that the actual member object(s) is there as expected. However, while it looks OK at first glance – all the expected fields – much of the core code relies on $members_template->member->user_id. But this doesn’t exist in the object. There’s ID and id keys, populated with the correct value, but no user_id. What am I missing here?

Viewing 1 replies (of 1 total)
  • This hack works, though not sure why it’s necessary. Just inside the loop:

    global members_template;
    if ( empty( $members_template->member->user_id ) ) :
    	$members_template->member->user_id = bp_get_member_user_id();
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar