dane-m
9/14/2013 - 5:30 AM

Get the number of users currently assigned to specified role.

Get the number of users currently assigned to specified role.

function count_users_by_role( $user_role ) {
 
        // Standard User Roles: all, administrator, editor, author, contributor, subscriber
 
        $result         =       count_users();
        $totalUsers     =       $result['total_users'];
         
        if( 'all' == $user_roll || '' == $user_roll ) :
                return $totalUsers;
        else :
                return $result['avail_roles'][$type];
        endif;
}