Skip to:
Content
Pages
Categories
Search
Top
Bottom

Listing members alphabetically


  • Zoe Ellison
    Participant

    @zoe-ellison

    I have listed my members alphabetically by their last name adding this to functions.php in my child theme:

    function alphabetize_by_last_name( $bp_user_query ) {
        if ( 'alphabetical' == $bp_user_query->query_vars['type'] )
            $bp_user_query->uid_clauses['orderby'] = "ORDER BY substring_index(u.display_name, ' ', -1)";
    }
    add_action ( 'bp_pre_user_query', 'alphabetize_by_last_name' );

    And this in members-loop.php

    
    
    <?php if ( bp_has_members( bp_ajax_querystring( 'members' ).'&type=alphabetical' ).'&exclude=1,4,3,5,512 ' ) : ?>
    
    

    However some members have their middle names in the same field as their first name and somehow they are being listed in order of the middle name.

  • The topic ‘Listing members alphabetically’ is closed to new replies.
Skip to toolbar