WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Which function can be used to get the user's object using the username? I've tried get_userdatabylogin() but the function seemed to throw an error:

Parse error, unexpected T_STRING on line xx

The function was called like so:


share|improve this question
up vote 5 down vote accepted

That function should do what you want. Are you sure the error is not elsewhere?

You can also try using the get_user_by()(source) function:

$user = get_user_by('login', 'MaryJane');

This is the same as get_userdatabylogin('MaryJane');

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.