SocialEngine Zend getting user profile picture

2019-04-15 04:46发布

问题:

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.

回答1:

$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)



回答2:

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



回答3:

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