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 need to retrieve the id of a role by giving it roles name. For example:

if( current_user_can('editor') ) {
 //here I want to retrieve the id of editor.
}

How can I do that?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Try buildin function get_users. The code should be like that:

$args = array(
    'role' => 'editor'
);
$editors = get_users($args);
foreach ($editors as $user) {
    echo '<li>' . $user->ID . '</li>';
}
share|improve this answer
    
It works, thanks for your prompt reply.:) –  dev-jim Jun 19 '12 at 17:32

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.