Doing my first delving into some add-on work. In an add-on (module, in this case), how do I get the avatar URL of the currently logged in user? I want to do this:
$login_data = array(
"id" => $this->EE->session->userdata('member_id'),
"username" => $this->EE->session->userdata('screen_name'),
"email" => $this->EE->session->userdata('email'),
"url" => $this->EE->session->userdata('url'),
"avatar" => ???
);In the docs, avatar is not available as part of the user session the way all the other things I’m pulling are.
Hoping this is an easy one. Thanks!
user session doesn’t store avatar info. To get avatar/avatar url, you have to write extra query: like:
$this->EE->db->select('avatar_filename');
$this->EE->db->from('members');
$this->EE->db->where('member_id', $this->EE->session->userdata('member_id'));
$query = $this->EE->db->get();
$avatar_url = $this->EE->config->item('avatar_url').$query->row('avatar_filename');hope this would help you.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.