Sorted…… found mycustom_ids function and membersloop
Just need to sort how to display the details.
Happy Days
Ok, all working but how can i Get members-loop to sort on the last name? or better still, show username by last name, first name
Any hints, clues, pointers welcome 🙂
Could you share your code to show First Name and Last name? I’m trying to get this to work with Memberpress. Thanks!
I found and added this code to my functions.php within my theme folder – this allows you to sort the members by lastname.
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' );
I then created a custom page template within my theme and pasted the membersloop.php code into that page and made some formatting changes as I only wanted it to affect this one page.
On the line:
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ) ) ) : ?>
I added ‘&populate_extras&type=alphabetical’
so the line now shows as:
<?php if ( bp_has_members( bp_ajax_querystring( 'members' ) . '&populate_extras&type=alphabetical' ) ) : ?>
Hope that helps.
Thanks @mrdrabble that worked a treat!