Show different badge based upon the user role


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 } ?>

Solutions Collecting From Web of "Show different badge based upon the user role"