0
if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) :
    do_action( 'bp_before_directory_members_list' );
        while ( bp_members() ) : bp_the_member();
            // the loop content goes here.
            // hoping that highscorers will be
            // displayed first and foremost
        endwhile;
    do_action( 'bp_after_directory_members_list' );
    bp_member_hidden_fields();
else:
    // and then the were none
endif;`

Let’s say we have a simple members loop code just like the one above. And let’s say that all of our members have this xprofile field named “Test Score” filled accordingly.

Can we sort out the loop output so it displays members with highest “Test Score” first?

No, I don't need extra filter options or anything (like the standard dropdown options of "Last Active","Newest","Alphabetical","Random",etc), just straight out change the ordering of the members list.

So members with highest "Test Score" xprofile field value will always by displayed first and foremost. without any other sorting/ordering option.

Thank you.


I have previously asked similar question in buddypress forum, but I didn't get much luck on that side... the same when I googled for similar problems. People keep saying buddypress codex (with links) has the answer, yet for the love of sugar, I cannot get my head over how to use the content of those links to help me with my task. So yeah... maybe I'm just an idiot, so feel free to think of me as one when you answer.

Here's a few of the links which was said could help me solve my problem:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.