Skip to:
Content
Pages
Categories
Search
Top
Bottom

Resetting a has_members query

  • Avatar of aaclayton
    aaclayton
    Participant

    @aaclayton

    Hey BP community,

    I built myself a handy little “Who’s Online” widget that displays the number of current active members and displays up to 10 names of current browsers in my footer.

    The only issue I have with it is on any page that already uses a bp_has_members() loop, the arguments of the main loop override my Who’s Online listing, causing it to repeat the same list of users.

    I know with a WordPress posts loop I can use wp_reset_query() to destroy any existing queries to use multiple loops on a page. Is there a buddypress equivalent function for has_members()?

    Thanks!
    Andrew

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of Chouf1
    Chouf1
    Participant

    @chouf1

    Hi,

    sorry to ask that, but why don’t you use the built in BP widget Who’s online ?
    for inspiration, see how it is built in bp-core-widget.php:124
    You can also use bp-skeleton to built your own widget on a proper maner.
    http://wordpress.org/extend/plugins/buddypress-skeleton-component/

    Avatar of aaclayton
    aaclayton
    Participant

    @aaclayton

    I had built some functionality into my widget which the stock BP who’s online didn’t incorporate. My code is actually pretty similar to the stock widgets in bp-core-widget, but yet I run into this issue where any other has_members query contaminates the contents of my widget. There must be some trick that I’m missing to initiate a has_members query that resets any pre-existing query…

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

You must be logged in to reply to this topic.