0

I am trying to fetch all users with a specific role eg blogger and blogger_pro but my code just returns all users rather than those with that specific role. Hope someone can tell me whats wrong?

The above roles have been added using the plugin User Role Editor

Function:

function get_role_specific_users($role){
    $args = array(
        'role'    => $role,
        'orderby' => 'user_nicename',
        'order'   => 'ASC'
    );
    return get_users( $args );
}

And then calling it like this:

$pro_authors = get_role_specific_users('blogger_pro');
$authors = get_role_specific_users('blogger');

But both arrays just contains all users rather than those with that role :/

2
  • May be this will help you as this question already answered . ClickHere Commented May 31, 2018 at 13:50
  • That was the first thing i tried, but the examples there return all users to me, rather than role specific users :/
    – Alexander
    Commented May 31, 2018 at 15:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.