Reply To: [Resolved] Sort user list by last name
Okay – so I have this
<?php if ( bp_has_members( bp_ajax_querystring( ‘members’ ).’&type=alphabetical’ ) ) : ?>
in the members-loop.php file and it sorts the users alphabetically by user name.
BUT if I put this:
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' );
into the functions.php file I get this error message after it returns one user:
Fatal error: Call to undefined function bp_member_alphabetical() in /home/homepatr/public_html/wp-content/themes/twentyfourteen-child/buddypress/members/members-loop.php on line 57
And here is a copy of line 57:
<div class="item-meta"><span class="activity"><?php bp_member_alphabetical(); ?></span></div>
I’m just a homeschool mom/volunteer trying to get our support group web site up the way we need it. This is definitely a learning experience for me, and I appreciate all the help!