There is a better way to do this as of WordPress version 3.7. Use the WordPress property meta_key to select the last name property and then orderby => meta_value with an ascending order.
<?php
$args = array(
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC'
);
$user_query = new WP_User_Query( $args );
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $author ) {
// Line below display the author data.
// Use print_r($author); to display the complete author object.
?>
<a href="https://wordpress.stackexchange.com/questions/30977/<?php echo get_author_posts_url($author->ID); ?>" class="author"><?php echo get_avatar($author->ID, 96); ?><?php echo $author->display_name; ?></a>
<?php
}
}
?>
Related Posts:
- Wp_User_Query not sorting by meta key
- WP_User_Query with combined meta query – not working?
- pre_user_query meta_query admin user list
- How to use search_columns in WP_User_Query?
- How to query users who have empty first_name?
- WordPress User getting added with id of 0
- WP User Query fails when searching meta queries and search columns
- Getting users by specific capability, not role
- how to know when the user is in specific part of the website and when he leaves that part and display the data in the admin dashboard
- WP_User_Query – searching multiple fields
- Accessing current users data within a plugin
- How to activate the user search
- List Users alphabetically with heading
- is_user_logged_in() throwing undefined function error
- How to get the count
- How can I prevent certain custom roles from seeing other custom roles on the user list page?
- Display the line breaks in user bio without using html
- User with same Mail but a different additional info(like domain)
- SQL to set Display Name to First Name + Last Name
- Cannot update newly added User field using wp_update_user
- Getting user data via ajax
- Find count of WordPress users by role and search string for user name
- Sort users by custom user meta value
- Show only users with the same role in Dashboard user list
- Find out if logged in user is not subscriber
- Get multiple roles with get_users
- How to Merge Two Authors Into One?
- Whats the best way to share user data across multiple WordPress websites?
- User-edit role setting distinct from wp_capabilities? [closed]
- How can 2 blogs share the same users
- Different back-end language for different users?
- Migrating WordPress users into Disqus
- How to display the status of users (online – offline) in archive.php
- Remove email verification when new user register
- How to change user`s avatar?
- How to display custom user meta from registration in backend?
- Grouping users under parent user
- Check if specific username is logged in
- How to update user role without logout
- How to create a public profile for authors/contributors/users?
- How to insert new values to WordPress user Firstname and Surname Fields via DB
- How we can get the user id by its display_name
- How to change WordPress user ID?
- How to assign an additional/extra/second user-role to multiple users (of a specific user-role)
- Can I hook into the invite user process to verify their email address is from a certain domain?
- wp_insert_user is not working for me?
- How to customize wp_signon()
- Is it possible to get a user with just the password field?
- Is there any way to access Ultimate Member’s custom fields?
- How to add country drop down menu to the user profile?
- New user notification doesn’t include activation link
- Use phpbb user database for WordPress
- User ability to favorite or ‘like’ content
- Users roles, make a page belonging to multiple users
- Add custom fields to the user profile
- Undeleting a deleted user
- A way to count logged in users and display count?
- stop login if user_status equal zero
- Disable user profile editing for one user
- Is it possible to get the currently logged in admin’s IP?
- Rule to redirect non logged in User to Custom Registration/login Page in .htaccess file
- How do i make my wordpress website private?
- Sort users by userID by default on users.php
- How to delete user on logout and when session expires?
- Remove Capabilities from WP admin for specific user role
- wordpress user roles are not working
- What is proper way to store info such as user marking a post as favorite? In post meta or user meta?
- What are some best practices for user exit strategy?
- Is there a way to identify a user in a custom REST API method? [duplicate]
- wordpress disable login for unverified user
- Problem with automatic role change through cron job
- Profile page for user roles
- User description only displayed for logged user
- Allow users to create post without logging in?
- WordPress Password security related questions
- Assign random (and unique) user meta upon registration
- wp_dropdown_users() to include null value
- Adding more fields to the add user page on dashboard
- How can I clone a suscriber profile in wordpress
- Reading additional fields in PMPro
- How to put the ‘assign to new user’ select when you delete a user that has custom post type posts, but no normal posts
- How can I show a button in WordPress but make it unclickable unless logged in?
- How to display extra fields for user
- How to make WordPress ‘editor’ role to list/view/add/edit users only with the role ‘author’?
- How to grab data after wp user search is complete
- User email verification without a plugin, is it possible?
- Add method for tracking who referred new users
- User count only for role frontend vendor
- Giving users an editable homepage/business directory
- Buddypress – New user type with no profile and can’t interact but can be admin of a group
- Store subscription details for users in WordPress
- Disable editing profile for second time
- Remove @gmail.com from WordPress username
- How to create a specific role to manage users
- How to track all users logged into a site?
- Export user data from Squirrly’s Starbox plugin?
- Force Profile link for username, and stop “Website” field on Profile from becoming offsite link atop Comments, in “Recent Comments” list, etc
- Will users still be able to log in if I change host?
- Is there a way to resend confirmation emails?
- Add Additional Column in “Users” Dashboard Area – BP Extended Profiles (WordPress)