Skip to:
Content
Pages
Categories
Search
Top
Bottom

problem in display order – bp_has_member


  • 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)

  • 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.


    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.


    Diego Mariano
    Member

    @diego-mariano

    populate_extras not work! :(

    In which file to find the function bp_core_get_users()?


    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?


    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’)):
    `


    haydenjameslee
    Participant

    @haydenjameslee

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


    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

    BP_User_Query

    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.
Skip to toolbar