• 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)
  • Hi @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

    (@kosmicbird)

    @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!

    Hi @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

    (@kosmicbird)

    Hey @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!

    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.