TL;DR: Here’s how you can use SQL to find WordPress users by metadata. This is useful when you have information such as their first name and last name and want to retrieve the full WP_User
.
WordPress provides a number of functions that make it easy to retrieve a user based on certain information. One of the most popular functions (or most useful, maybe?) is get_user_by
.
However, what if you’re working on a system that maintains the user’s first name and last name or some other type of data point in the usermeta
table and you want to use that to retrieve the user’s information?