Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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;
share|improve this answer
    
Thanks Vinicius. –  user1460692 Jul 25 '12 at 6:33

There is a nice native function called get_user_by

http://codex.wordpress.org/Function_Reference/get_user_by

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

Your Answer

 
discard

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.