News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Get a specific user's avatar?

Started by AJ32, August 16, 2008, 11:48:19 PM

Previous topic - Next topic

AJ32

I'm writing a mod for my SMF 2.0 Beta 3.1 forum, and I need to get a specific user's avatar.
Is there a function in function_db, or a database query, etc. that will do this?

Thanks.  :)

Nathaniel

If you call the 'loadMemberContext($user_id)' function from 'Subs.php', then you can access a whole lot of information about each user. After you call the function, you can access the information from the $memberContext[] array, indexed by user ids. You want the $memberContext[$user_id]['avatar']['href'] or $memberContext[$user_id]['avatar']['image'] variables to get the avatar information. Its all setup by the 'loadMemberContext()'.
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

AJ32

Thank you, but the picture still doesn't seem to come up, it's probably a problem in my code...


require_once($sourcedir . "/subs.php");

foreach($UserArray as $user)
{
loadMemberContext($user['ID']);

echo '<tr>
<td class="windowbg">
'.$memberContext[$user['ID']].'
</td>';
        }



Thanks!

Nathaniel

I just realised that you also have to call the loadMemberData() function for each member as well. ;)

Also, you need to use the $memberContext[$user['id']]['avatar']['image'] information.

Try this:
   echo '
   <table>';
   foreach($UserArray as $user)
   {
      loadMemberData($user['id']);
      loadMemberContext($user['id']);
     
      echo '
         <tr>
             <td class="windowbg">
            '.$memberContext[$user['id']]['avatar']['image'].'
             </td>
         </tr>';
      }
   echo '
   </table>';
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

AJ32

Ah, that worked, thank you!

One of the things I wasn't doing was making $memberContext a global! ;)


Thanks!

Advertisement: