You need this code...yep had this problem before :)
Thanks, it works! :)
I would vote this best answer again if I could- worked great!
@windhack your code work fine, but it only read userinfo nr 1 !!!
this removes this problem:
http://www.concrete5.org/community/forums/customizing_c5/how-to-rem...
this removes this problem:
http://www.concrete5.org/community/forums/customizing_c5/how-to-rem...
$u = new User(); $userName = $u->getUserName(); $ui = UserInfo::getByUserName($userName); if ($ui->hasAvatar() == true) { echo '<img src="'.BASE_URL.DIR_REL.'/files/avatars/'.$ui->getUserID().'.jpg'.'" alt="'.$userName.'" />'; }
Hi There, I applied this to the page list on my home page, and it works perfectly fine when I'm logged in, but when I log out and look at the page it show this fatal error... what am I doing wrong?
Fatal error: Call to a member function hasAvatar() on a non-object in /home/smi65/public_html/websitenam.com/conc/concrete/blocks/page_list/view.php on line 26.
On line 26 it's: if ($ui->hasAvatar() == true) {
Fatal error: Call to a member function hasAvatar() on a non-object in /home/smi65/public_html/websitenam.com/conc/concrete/blocks/page_list/view.php on line 26.
On line 26 it's: if ($ui->hasAvatar() == true) {
I have this exact same problem, did you fix this?
Sorry to resurrect and old thread but I think this is a better answer. A little cleaner. Uses helpers.
<?php $username = $c->getVersionObject()->getVersionAuthorUserName(); $ui = UserInfo::getByUserName($username); $full_name = $ui->getAttribute('full_name'); if ($ui->hasAvatar()) { $avPath = Loader::helper('concrete/avatar')->getImagePath($ui); //Path to user avatar } else { $avPath = Config::get('concrete.icons.user_avatar.default'); //default icon path if no avatar } ?> //HTML OUTPUT <img class="avatar avatar_img" src="<?php echo $avPath; ?>" alt="'.$full_name.'"/>