WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


I have authors page and I need to display a different badge for Authors and Subscribers. Authors on the site have certain abilities that differ from Subscribers and I would like to display a different badge based upon their role.


So when somebody comes to the site either admin author, visitor subscriber... they see the badge on the authors page they are visiting based upon their role. If they are looking at the user who's role is 'Author' than the badge is green, and if the users role is 'Subscriber' then the badge is red. Is it possible and how do I make it?

This code doesn't do the trick :(

I was trying to go with this logic but it shows the badge based upon who is looking the authors age not of the author who owns the page. Please help :)

 <?php if( is_author_of_current_page() &&  current_user_can('Author') ) { ?>

  green badge

 <?php } elseif( is_author_of_current_page() &&  current_user_can('Subscriber') ) { ?>

  red badge

 <?php } ?>
share|improve this question
up vote 2 down vote accepted

You can use get_queried_object to get data in the current author page:


$author = get_queried_object();

// uncomment next line to see all author data
// print_r( $author );

if( in_array( 'author', $author->roles ) ) :

    echo "author";

elseif( in_array( 'subscriber', $author->roles ) ) :

    echo "subscriber";

share|improve this answer
thanks You, that's exactly what I was looking for. You rock! – jimilesku Jul 28 '12 at 12:50

Your Answer


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.