My goal is to attach a users role as a class to their user name anywhere it is displayed so I can color the link based on role.
I can get roles of every displayed user link using MYTHEME_username_alter
:
function MYTHEME_username_alter(&$name, $account) {
$user = user_load($account->uid);
// I can get the roles of each user link through $user
}
- Is this the most efficient way to get the role for each user link?
- What is the best way to go about adding the role as a class to every user link?
- Am I way off track and overlooking an easier way to complete my goal?