Skip to:
Content
Pages
Categories
Search
Top
Bottom

problem in display order – bp_has_member

  • Avatar of Diego Mariano
    Diego Mariano
    Member

    @diego-mariano

    Hello,

    I’m having trouble showing the members of my social network through bp_has_members.

    I need to display them in a specific order. For this I created a function that takes data from a table outside and BuddyPress stores ids of members and other information (called table “filter”).

    This function returns the ids separated by comma.
    So I use the optional attribute “include” inside the loop.

    The explanation is a little complex, but I will show in practice. Looks like this:
    if (bp_has_members (‘include =’. $ id. ‘& per_page = 30′)):

    Where, example, $id = ’8, 9,3,2 ‘;

    But the BuddyPress rearranges the display order of the members this way:
    2,3,8,9

    I need it to display the members in order that I sent:
    8,9,3,2

    Can anyone help me solve this? Thank you.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    Afaik, bp_has_members will default to sorting the returned array by ‘last_active’, thereby wiping out the order of your $id string.

    Using populate_extras might stop that:

    `
    if (bp_has_members (‘include =’. $ id. ‘& per_page = 30& populate_extras=false’)):
    `

    BuddyPress doesn’t use that parameter for any sort of ordering. It’s just an array of IDs to be included in the query. The ‘type’ parameter controls this; see bp_core_get_users().

    I think you would have to re-order the results of the query after it is made.

    Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    The returned users are always sorted by the ‘type’.
    I’ve never tried setting ‘type’ to null …?

    It would be great to have a ‘type = unsorted’ (enhancement ?)
    I’ve had tasks where that would be very handy.

    >I think you would have to re-order the results of the query after it is made.
    That’s tough to do – and still use the members-loop and pagination.

    Avatar of Diego Mariano
    Diego Mariano
    Member

    @diego-mariano

    populate_extras not work! :(

    In which file to find the function bp_core_get_users()?

    Avatar of Diego Mariano
    Diego Mariano
    Member

    @diego-mariano

    I thought about doing something like:

    for($x=0;$x<30;$x++)

    q but I think the performance will be impaired.
    What do you think?

    Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    Probably won’t work, but try these and let us know:

    `
    if (bp_has_members (‘include =’. $ id . ‘&per_page = 30&type=NULL’)):
    `

    `
    if (bp_has_members (‘include =’. $ id . ‘&per_page = 30&type=dummy’)):
    `

    Avatar of haydenjameslee
    haydenjameslee
    Participant

    @haydenjameslee

    I have the same problem as this post and have tried your solutions with no luck shanebp. Any further ideas?

    Avatar of shanebp
    shanebp
    Moderator

    @shanebp

    Yes, BP_User_Query now supports preserving the order the ‘user_ids’ parameter.

    So if you’re using a function to collect member ids, take a look at

    http://codex.buddypress.org/developer/bp_user_query/#code-examples

    Note the last entry.

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

The topic ‘problem in display order – bp_has_member’ is closed to new replies.