We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Get avatar of logged in member

Development and Programming

struiling's avatar
struiling
10 posts
13 years ago
struiling's avatar struiling

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!

       
Bhashkar Yadav's avatar
Bhashkar Yadav
727 posts
13 years ago
Bhashkar Yadav's avatar Bhashkar Yadav

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.

       
struiling's avatar
struiling
10 posts
13 years ago
struiling's avatar struiling

This is exactly what I was looking for. Thank you!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.