Title: Display editors only
Last modified: August 19, 2016

---

# Display editors only

 *  [wearebase](https://wordpress.org/support/users/wearebase/)
 * (@wearebase)
 * [16 years ago](https://wordpress.org/support/topic/display-editors-only/)
 * Hi There,
 * I am having an issue trying to diplay users with the level ‘editor’ only can 
   anyone point our the obvious in the following?
 *     ```
       <?php foreach ( get_users_of_blog() as $author ) : ?>
             <?php $user = new WP_User( $author->ID ); ?>
             <?php if ( $user->has_cap( 'publish_posts' ) || $user->has_cap( 'edit_posts' ) || $user->has_cap( 'publish_pages' ) || $user->has_cap( 'edit_pages' ) ) : ?>
             <div id="hcard-<?php echo str_replace( ' ', '-', get_the_author_meta( 'user_nicename', $author->ID ) ); ?>" class="author-profile vcard clear"> <a href="<?php echo get_author_posts_url( $author->ID ); ?>" title="<?php the_author_meta( 'display_name', $author->ID ); ?>">
               <?php the_author_image($author->ID);?>
               </a>
               <h2 class="author-name fn n">
                 <?php the_author_meta( 'display_name', $author->ID ); ?>
               </h2>
               <p>
                 <?php
       			$user_bio = get_the_author_meta( 'description',  $author->ID );
       			echo nl2br("$user_bio")
       		 ?>
               </p>
               <!-- .author-bio --> 
   
             </div>
             <!-- .author-profile .vcard -->
   
             <?php endif; ?>
             <?php endforeach; ?>
       ```
   

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years ago](https://wordpress.org/support/topic/display-editors-only/#post-1555195)
 * After this:
 *     ```
       <?php $user = new WP_User( $author->ID ); ?>
       ```
   
 * put
 *     ```
       <?php
       $test_for_role = 'editor';
       $has_role = false;
       if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
         foreach ( $user->roles as $role ) {
           if ($test_for_role == $role)
             $has_role = true;
         }
       }
       if ($has_role)
         echo 'this user is has the '. $test_for_role . ' role';
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Display editors only’ is closed to new replies.

## Tags

 * [users](https://wordpress.org/support/topic-tag/users/)

 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years ago](https://wordpress.org/support/topic/display-editors-only/#post-1555195)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
