Earlier today I was working on a user-account class that talks to an api and needed to get the associated user_id from the returned value. All I had to from was a custom user_meta value and the meta_key. I figured there would be a wp function called get_user_id_by_meta, or something similar, but I didn’t find one. So, I made one.

This function is rather simple, but could easily be much more. This function is actually a method in a class so the naming convention is safe. However, if you plan to use it outside of a class I suggest that you change the name.

Get a WordPress users id from meta_key and meta_value:

If you found this helpful please let me know. If you have any questions, comments, or a more efficient way let me know.