Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
So now the $account variable holds all the information about your node's author.
The tricky part is that sometimes the author can have more than one role, so you may want to print them all out with commas separating them.
<?php
$author_roles = array();
foreach ($account->roles as $key=>$value) { //cycle through each role the author has
$author_roles[] = $value;
}
echo implode(', ', $author_roles); //comma separation
?>
Comments
Hi hellomobe- First you need
Hi hellomobe-
First you need to load the information you want since it isn't available automatically in the node:
<?php $account = user_load(array('uid' => $node->uid)); ?>So now the $account variable holds all the information about your node's author.
The tricky part is that sometimes the author can have more than one role, so you may want to print them all out with commas separating them.
Hope that works for you.
-Amanda
Thank you Amanda! I also
Thank you Amanda!
I also found this to eliminate the "authenticated user". I modified ithe code from the link below with your user_load()
source: http://blog.riff.org/2005_08_24_drupal_admin_displaying_user_roles_on_th...