SocialEngine Zend getting user profile picture

2019-04-15 04:39发布

I am trying to get a users profile picture by using

$this->itemPhoto($this->viewer(), 'thumb.icon');

or

$this->htmlLink($this->viewer()->getHref(), $this->itemPhoto($this->viewer(), 'thumb.icon'))

The this->viewer gets the person who is viewing the page and outputs their user_id and a link. I mimicked the output of that but it refuses to accept it. It errors out with 'Item must be a valid item." I have searched through the code and when users upload images it for some reason is hashed and put into hashed folders which i can't just pull from. But using the above functions do not work if i wanted to get the profile picture of someone else besides the current viewer or pageSubject. Does anyone know how to get this thing to work?

The lack of socialengine help and awful api are making this hard.

3条回答
姐就是有狂的资本
2楼-- · 2019-04-15 04:57

This will print image with profile link.

<?php
$member2 = Engine_Api::_()->user()->getUser($user_id);
echo $this->htmlLink($member2->getHref(), $this->itemPhoto($member2, 'thumb.icon'), array('class' => 'placement_members_icon'))

?>

replace $user_id in first line with desired user id.... that you can get easily from any table or user table

查看更多
\"骚年 ilove
3楼-- · 2019-04-15 04:58

You could also use: $this->viewer()->getIdentity().

查看更多
做自己的国王
4楼-- · 2019-04-15 05:03

$this->viewer() actually is the logged-in user's object. If your user is not logged in this code won't output anything.

Edit: It is the user object. You can use Engine_Api::_()->user()->getViewer() or if you know the user_id/email of viewer, Engine_Api::_()->user()->getUser($user_id)

查看更多
登录 后发表回答