Drupal 7: using EntityFieldQuery to get uid from username

Friday, February 3, 2012

I was in a situation where I needed to retrieve the $user->uid from the username in Drupal 7. A number of cursory web searches did not quickly lead me to an example. While it's fairly straightforward to do this once you understand EntityFieldQuery and the differences between propertyCondition, fieldCondition, etc., I've been a bit surprised that there aren't more examples for this type of use case that pop up prominently in search results. I suppose documentation and examples take time...

Without further ado...

Kevin's Bookmarks