WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been looking into wpse archives to solve my problem but I can't manage to do such a thing. I built this code :

$args = array('fields' => 'all_with_meta');
$users = get_users($args);
foreach ($users as $user) {
       echo esc_html( translate_user_role( ucfirst ( $user->roles[0] ) ) );

I made a print_r()to see what I get. Everything is fine, I mean I grab user role but it does not translate by itself. Do I need to do more?

share|improve this question

I think your function nesting is slightly muddled; call ucfirst after translating, like so:

esc_html( ucfirst( translate_user_role( $user->roles[0] ) ) );

My bad, completely skipped a beat there. You should instead be using:

translate_user_role( $GLOBALS['wp_roles']->roles[ $user->roles[0] ]->name );

It's unreliable to assume that all role display names are simply ucfirst( $role key ). If that still does not work, are you sure the language files you're using have fully translated WordPress?

share|improve this answer
right I've changed it but that does not solve my problem – JMau Jun 26 '13 at 12:44
Answer changed. – TheDeadMedic Jun 26 '13 at 13:01

Your Answer


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.