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 use the following code to get the Administrator role

$admin = get_role('administrator');

This works fine, but on a different WordPress language setup, this code breaks. For example, in French it should be

$admin = get_role('adminstrateur');

Any cross-language solution?

share|improve this question
Interesting question. +1 I never noticed this (using german lang installations), but maybe you have/had some role manager, membership or capability editor plugins installed? – kaiser Apr 5 '12 at 4:32
up vote 1 down vote accepted

Just guessing, but maybe:

$admin = get_role( __( 'administrator' ) );

If you're trying to make sure that WP translates the string for a specific locale, __() will return the translated string. So if get_role('administrator') works and on a French setup get_role('administrateur') would work, then the above code snippet should do what you need.

share|improve this answer
but per my knowledge you need to provide the translation file, no? – Omar Abid Apr 4 '12 at 22:30
Calling __( 'some text' ) is identical to calling __( 'some text', 'default' ) ... it will use WP's default text domain. – EAMann Apr 4 '12 at 23:05
I guess it would be (uppercase 1st char) Administrator. – kaiser Apr 5 '12 at 4:30
It works and not. I'm not really sure but it fixes the bug. Anyway, I'm rewriting the roles class in the future, so that's a temp hack. – Omar Abid Apr 5 '12 at 18:50

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.