How to display user role on author page.
I have created my own role (group) so I want to display the user role on below the post and on author list.
I have tried this code but not working as its calling current_user and its showing current user role in all authors profile
<?php
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
if ($user_role == 'administrator') {
echo 'Administrator';
} elseif ($user_role == 'editor') {
echo 'Editor';
} elseif ($user_role == 'author') {
echo 'Author';
} elseif ($user_role == 'contributor') {
echo 'Contributor';
} elseif ($user_role == 'subscriber') {
echo 'Subscriber';
} else {
echo '<strong>' . $user_role . '</strong>';
}
?>
How can I alter this code to display user actual role and not the current user role.