• 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)
  • 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.