Skip to:
Content
Pages
Categories
Search
Top
Bottom

Display groups in member search


  • Hiranthi
    Participant

    @illutic

    Last year I’ve written a member management plugin for a client which is working great, there is one thing that’s bugging us though:

    By default a few things are displayed on the overview pages:

    – Name
    – Values of some xprofile fields
    – Groups the user is a member of

    Searching the profiles works great too, but here’s the thing that’s bugging us: the groups aren’t displayed anymore.

    I can’t, for the life of me, figure out why it’s doing this. I’ve set the if statement for the groups-loop to this: if ( bp_has_groups( 'user_id=' . bp_get_member_user_id() . '&type=alphabetical&s=&search_terms=&search_term=&max=100' ) ) but it doesn’t work (notice the empty s, search_terms and search_term).

    I couldn’t find any search-related options for the bp_has_groups function, but it is going wrong there (since they’re displaying fine when you’re just browsing the profiles).

    I also know the bp_get_member_user_id() is working perfectly inside the user-loop, so that shouldn’t be the issue either.

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

  • shanebp
    Moderator

    @shanebp

    >I also know the bp_get_member_user_id() is working perfectly inside the user-loop, so that shouldn’t be the issue either.

    Classic mistake. Don’t assume – check it.
    Create a string and echo it out.

    $user_id = bp_get_member_user_id();
    echo 'user_id: ' . $user_id;
    
    $args = array(
         'type' => 'alphabetical',
         'user_id' => $user_id
    );
    if ( bp_has_groups ( $args ) ) { ...
    

    Hiranthi
    Participant

    @illutic

    Classic mistake. Don’t assume – check it.

    No assumption, a fact. Like I said (and you quoted):

    I also know the bp_get_member_user_id() is working perfectly inside the user-loop, so that shouldn’t be the issue either.

    The code on that page looks roughly like this:

    – if & while – members loop
    – – Display Profile & xProfile data, using the bp_get_member_user_id() function to retrieve the userID (which I mentioned).
    – – if & while – groups loop of that specific member

    The last if & while (the groups loop) works perfectly on the default overview page, it’s displaying the groups for every member on their corresponding row in the html-table.

    BUT: as soon I start searching (whether it’s the name of the member, or part of the address) the groups-loop stops working. All other things still work (Profile & xProfile field values are still getting displayed), but the groups-list per member doesn’t display anymore.

    With checking on a per-group basis the same thing happens: on the overview page of that group it works perfectly, until I start searching: everything but the groups display.

    What I completely forgot about: it’s also doing this with the groups-list I’m displaying on the top of the overview pages to filter the members per group. When on the all-overview page it’s displaying the groups fine, but once you start searching the only thing in that submenu/filtermenu is the All option.

    I’d love to provide screenshots of this, but unfortunately I’m dealing with private information here, and very specific group-names, so I don’t want to display that here in the open.


    shanebp
    Moderator

    @shanebp

    You don’t state which version of BP you’re using.

    >as soon I start searching (whether it’s the name of the member, or part of the address) the groups-loop stops working.

    If I understand you correctly, bp_has_groups doesn’t ‘work’ if you include search terms.

    Perhaps it is working but the search terms are not being found, so no groups are being returned.
    I’m not positive, but I think the search is only on the name and description of a group.
    Take a look at function search_groups in bp-groups-classes.php

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display groups in member search’ is closed to new replies.
Skip to toolbar