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 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
add comment

1 Answer 1

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
add 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.