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'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

1 Answer 1

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

 
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.