Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am currently calling a user's nicename in a function I have:

   $users = $user_query->get_results();  
   foreach( $users as $user ):    
   echo $user->user_nicename; 

I'm trying to call the user's Nickname instead, but nothing I do is working such as:

    echo $user->user_nickname;

Is there a special way you have to call a user's nickname?

Thanks

share|improve this question
What does $user_query->get_results() return? – Chip Bennett May 21 '12 at 14:50

1 Answer

If you want to query all users, try using the get_users() function. Note that this function returns an array:

<?php
$users = get_users();

foreach( $users as $user ) {
    echo $user['user_nicename'];
}
?>
share|improve this answer
I have a custom code that provides a list of users based on certain criteria, but I am just not able to successfully call (and display) the user's nickname instead of their nicename. – Teddy May 21 '12 at 14:26
1  
How are we supposed to answer/help, without seeing this "custom code"? – Chip Bennett May 21 '12 at 14:37
I didn't think the code itself was really relevant, I was just asking in general for how to call a user's nickname. – Teddy May 21 '12 at 14:55
Okay, now I'm confused. :) If the code itself isn't really relevant, why did you bring it up? – Chip Bennett May 21 '12 at 15:41
I think I'm confused too... ;) Your original reply mentioned querying all users, which I am not doing. I am just trying to change the way my query displays on my page (using nickname instead of nicename) so that a user's first and last name will appear. – Teddy May 21 '12 at 16:22
show 1 more comment

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.