The MU forums have moved to WordPress.org

most efficient way to get a user_email from their user_id? (3 posts)

  1. fleshins
    Member
    Posted 14 years ago #

    Given a user's id, $user_id, the only way I see to get user_email is through get_userdata($user_id)->user_email

    Only thing I don't like about that approach is that get_userdata() returns a rather large object containing everything you could possibly want to know about the user. Since I'm only interested in the user's email address is there a more efficient way to get it?

  2. SteveAtty
    Member
    Posted 14 years ago #

    Its still going to have to query the database which is the expensive part, so the overhead of returning the full structure, instead of just the email address, is simply a matter of bytes which is the scope of things is minimal (a full user data row is about 710 bytes)

    You could of course simply query the DB directly.

  3. fleshins
    Member
    Posted 14 years ago #

    Thanks Steve - that's what I figured. Thanks for all of the replies!

About this Topic

  • Started 14 years ago by fleshins
  • Latest reply from fleshins