Get the meta data in the query and order by value?
$wp_user_search = $wpdb->get_results("
SELECT u.ID, u.display_name, um.meta_value
FROM $wpdb->users u
JOIN $wpdb->usermeta um ON um.user_id = u.ID
WHERE um.meta_key = 'yim'
ORDER by um.meta_value
ASC");
NOTE: There is a function for getting all the users incase you weren’t aware, called get_users_of_blog()
.
Mark,
Thank you very much for the code snippet. That solved the issue and gave me enough to know where I went wrong.
I had no idea of that function! If I had known this function last week, it could have saved me a ton of effort. Odd as I searched and searched here at wordpress.org but something like that never came up or I missed it.
Its great to see that now as I know I will be using this in the future.
Again, Thank You
I did have a dig around for a codex page for the function, couldn’t find one(guess i’ll make one at some point), so just gave you the function name.
Happy i could help though.. 🙂