Use global $authordata
:
Testing for roles:
global $authordata;
if ( in_array( 'administrator', $authordata->roles ) )
{
echo 'Hello Admin!';
}
elseif ( in_array( 'editor', $authordata->roles ) )
{
// echo something else
}
Or testing for capabilities:
if ( ! empty ( $authordata->allcaps['manage_options'] ) )
{
echo 'The author can manage options';
}
elseif ( ! empty ( $authordata->allcaps['edit_others_posts'] ) )
{
// echo something else
}