Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to order members list alphabetically by default

  • @leftblanx

    Participant

    Hi,

    I’m relatively new to WP and BP development, using WP 2.9.2 and Buddypress 1.2.2.1, and am wondering if and how it would be possible to filter the members list alphabetically by default.

    Furthermore, would it be possible to actually remove the ‘Order By:’ dropdown altogether?

    Also, the Search box returns results from each of my text profile fields when ordering by Newest Registered, but only is returning results from First Name and Last Name fields when ordering Alphabetically. Does anyone have any idea why this would this be the case?

    Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • @leftblanx

    Participant

    Anybody have any idea about these questions?

    With regard to the point in the final paragraph – when you sort the members list alphabetically, and then use the search facility, the SQL query looks like:

    SELECT COUNT(DISTINCT u.ID) FROM wp_users u LEFT JOIN wp_usermeta um ON um.user_id = u.ID LEFT JOIN wp_bp_xprofile_data pd ON u.ID = pd.user_id WHERE u.user_status = 0 AND (pd.field_id = 1) AND pd.value LIKE ‘%%searchterm%%’ ORDER BY pd.value ASC;

    It assumes pd.field_id = 1, which is the Name field – why does it assume you only care about searching on the Name field when ordering alphabetically? And how would I best modify this to search on a) the text values of all my text profile fields, and b) the labels on multiple option profile fields?

    @micb11

    Participant

    I am also trying to set the default of my members list to alphabetically instead of last active. I cannot find anywhere to show this. Can anyone help?

    @nuprn1

    Participant

    what params can be passed to the members loop (edit a theme file or create a child theme for members/index)
    https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-members-loop/

    but a small bug, if no xprofile data then not all the members will be returned
    https://trac.buddypress.org/ticket/1670

    @micb11

    Participant

    There must be a way to make the drop down default to alphabetically rather than activity.

    @perywinkle

    Participant

    Sorry to bring up a old post here, but…
    I’m inside of the members-loop.php, I see there is a bp_ajax_querystring(‘members’).
    How would I pass bp_has_members() a few parameters in combination with the above?


    Something like this:
    ` ‘newest’, ‘per_page’=> 15 ) ?>`

    I’d like to make the default filter ‘newest’ and have 15 members on a page.

    Thanks!

    Mic

    @perywinkle

    Participant

    This kinda worked, but then I lost the ability to filter by alphabetical, last active etc.
    But if your looking to NOT filter it might be a solution.
    `
    <?php /* My Custom Member Query */
    function my_query_filter_new ( $query_string ) {
    $query_string .= ‘&per_page=15&type=newest’;
    return $query_string;
    }
    add_filter( ‘bp_ajax_querystring’, ‘my_query_filter_new’ );
    ?>

    `

    @ekaliva

    Member

    In the Template-File members-loop-php I inserted the following Code at the top of the file:

    `

    <?php
    if ( bp_ajax_querystring( ‘members’ ) ==””)
    {
    $queryString = “type=alphabetical&action=alphabetical&page=1”;
    }
    else {
    $queryString = bp_ajax_querystring( ‘members’ );
    }
    ?>

    …`

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to order members list alphabetically by default’ is closed to new replies.
Skip to toolbar