Able to list all users from wp_users, now how to filter by usermeta?
-
I am able to query and show all of my users of my site, but now that I can do that, I cannot figure out how to get it to sort using the value that is within the “YIM” field in the user profile.
I basically just want to sort by Department (which I renamed the YIM field to) but I am not sure how to get that Order By into the code. Anybody out there than can point me in the right direction?Here is what I have now:
<?php $wp_user_search = $wpdb->get_results("SELECT ID, display_name FROM $wpdb->users ORDER BY ID"); foreach ( $wp_user_search as $userid ) { $user_id = (int) $userid->ID; $user_login = stripslashes($userid->user_login); $display_name = stripslashes($userid->display_name); $user_info = get_userdata($user_id); echo('<tr><td><a href="https://sv:81/?author=' . $user_id . '">' . $user_info->last_name . "</td>"); echo('<td>' . $user_info->first_name . "</a></td>"); echo("<td>" . $user_info->yim . "</td><td>" . $user_info->jabber . "</td></tr>"); } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Able to list all users from wp_users, now how to filter by usermeta?’ is closed to new replies.