I've tried searching for the answer to this, but just cannot find any description of examples of what I am trying to do.
I would like to link WP users to an external CRM. To provide the link, I have created a custom field against users called "External ID". How that external ID gets into that field is not the issue here; finding a user with a given ID is.
So, during login, a user is authenticated and that authentication process gives me the External ID. Now I want to use that External ID to find the WP user (if one exists) that has that ID in the custom field.
I am sure it is just a couple of lines of code, but I just can't see how to do it. Any hints on how I would do this?
In summary: users have a custom field, each with a unique ID string in. Given an ID, in code I would like to fetch the WP_User object for the user that matches that ID in its custom field.