Title: Using the get_userdata function
Last modified: October 15, 2016

---

# Using the get_userdata function

 *  [kosmicbird](https://wordpress.org/support/users/kosmicbird/)
 * (@kosmicbird)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-the-get_userdata-function/)
 * Hi all
 * I am not sure if this is the proper function I need to use for what I’m trying
   to do.
 * I have read the info in the Codex about get_userdata function but am still unclear
   on how to implement it or if this is the correct function I should be using.
 * I need to be able to display the username of a private message **recipient** (
   I know this is not a built in WP feature, I am trying to add on to an incomplete
   plugin that I am using).
 * I know how to get the info of the message **author** but have troubles getting
   the info of the recipient.
 * The Codex examples clearly show how to pull the data for a specific user
 * ie `<?php $user_info = get_userdata(1);` pulls the specified data for user 1
 * However I don’t need to specify a single user, I need it to be, I guess a “blanket
   statement” where it will pull the info of whoever the specific message recipient
   is.
 * Am I going in the completely wrong direction thinking to use get_userdata function
   for this? Any suggestions on how I can accomplish what I’m trying to do? How 
   can I use this function to pull the data for any user, not just one specific 
   user?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Adarsh Verma](https://wordpress.org/support/users/shobhit2412/)
 * (@shobhit2412)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-the-get_userdata-function/#post-8301964)
 * Hi [@kosmicbird](https://wordpress.org/support/users/kosmicbird/),
    If anyhow
   you get the ID of the recipient of the message, you can use the code that you
   are using like this:
 * <?php
    **$user_info = get_userdata( $user_id ); $username = $user_info->user_login;?
   >
 * This **“$username”** will be the username of the recipient of the message.
 * Thanks!
 *  Thread Starter [kosmicbird](https://wordpress.org/support/users/kosmicbird/)
 * (@kosmicbird)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-the-get_userdata-function/#post-8304636)
 * [@shobhit2412](https://wordpress.org/support/users/shobhit2412/) comes to the
   rescue again 🙂
 * I guess my issue now is that I can’t figure out what variable/ID I need to use
   in order to get the message recipient, who will always be a different person 
   so I can’t just use a certain number as the ID. Will have to keep digging…
 * Thanks again for your reply!
 *  [Adarsh Verma](https://wordpress.org/support/users/shobhit2412/)
 * (@shobhit2412)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-the-get_userdata-function/#post-8311015)
 * Hi [@kosmicbird](https://wordpress.org/support/users/kosmicbird/),
    I can help
   you in a more better way if you send some lines of code that you’re using. I’ll
   try to help you with your issue.
 * Thanks!
 *  Thread Starter [kosmicbird](https://wordpress.org/support/users/kosmicbird/)
 * (@kosmicbird)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-the-get_userdata-function/#post-8320778)
 * Hey [@shobhit](https://wordpress.org/support/users/shobhit/)
 * I ended up figuring it out (granted after 2 days 😜 of frustration)
 * Turns out I was looking at this issue the completely wrong way, but I have now
   solved it.
    Really, really appreciate your kind offer to help me. Thank you so
   much!
 *  [Adarsh Verma](https://wordpress.org/support/users/shobhit2412/)
 * (@shobhit2412)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/using-the-get_userdata-function/#post-8320902)
 * Glad that your issue is resolved! 😀

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Using the get_userdata function’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [Adarsh Verma](https://wordpress.org/support/users/shobhit2412/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/using-the-get_userdata-function/#post-8320902)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
