3

I want to display the user names by the reference of user id.

Is there any function like get_user_displaynme($userid)? (and one more Is there any shortcode to get group names?)

Thanks in Advance

3

You can use the very same get_userdata function of WordPress to code a specific function. Stick this in your functions.php:

function get_display_name($user_id) {
    if (!$user = get_userdata($user_id))
        return false;
    return $user->data->display_name;
}

So you can do something like:

$display_name = get_display_name($some_user_id);
echo $display_name;
| improve this answer | |
0

There is a nice native function called get_user_by

| improve this answer | |
  • Please don't just add links, it's better to offer an explanation in your answer. – Nicolai Nov 16 '13 at 15:08
0

This may not be an answer to this question, but in the end I reached for this question when I am looking for a way to fetch the display name for the user through the ID

$user_displayname = get_user_by( 'id', $userid )->display_name ;

So maybe someone else may benefit from my answer

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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