TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 408
  • Total: 408

[Block] Newest member block with Avatar image which links to their profile

Started by gbingo, August 23, 2006, 06:04:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jacortina

Latest member to SMF means the most recent to register. They might not have even activated their account, yet.

rebelrose

yes he has posted, if I use Fels code it just shows his avatar, if I use the first code it shows a x and the username with link to profile.

jacortina

Interesting.

Can you check your errorlog real quick and see if there's anything in the last few minutes.

rebelrose

512: loadMemberContext(): member id 57 not previously loaded by loadMemberData()
File: //public_html/forum/Sources/Load.php
Line: 950

jacortina

Well, let's see if include the Load.php fixes it:

global $memberContext, $sourcedir;
require_once($sourcedir.'/Load.php');
$user_id = $context['common_stats']['latest_member']['id'];
loadMemberContext($user_id);
if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$context['common_stats']['latest_member']['link'].'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$context['common_stats']['latest_member']['link'].'</div>';

rebelrose

It is showing the same as the last code, I have it in a test block on the left hand side, guest can view it if you want to look.

jacortina

No, that won't do it (or nott he right way if it does happen to work):

global $memberContext;
$user_id = $context['common_stats']['latest_member']['id'];
loadMemberData(array($context['common_stats']['latest_member']['id']));
loadMemberContext($user_id);
if (!empty($memberContext[$user_id]['avatar']['image']))
echo '<div align="center">'.$memberContext[$user_id]['avatar']['image'].'<BR>'.$context['common_stats']['latest_member']['link'].'</div>';
else
echo '<div align="center">( No Avatar Yet )<BR><BR>'.$context['common_stats']['latest_member']['link'].'</div>';



MeRcChRiS

how could we do it so it shows the persons posts count and  his most recent posts and other info of the user

feline

Quote from: RebelRose on September 28, 2006, 09:38:37 PM
Yes I got it now G6, it shows the avatar great, but not member name like in first code.

Fel Code:


global $context, $modSettings, $scripturl, $db_prefix;

$id = $context['common_stats']['latest_member']['id'];
$request = db_query("SELECT m.realName, m.avatar, a.ID_ATTACH
FROM {$db_prefix}members AS m
LEFT JOIN {$db_prefix}attachments AS a ON (m.ID_MEMBER = a.ID_MEMBER)
WHERE m.ID_MEMBER = $id", __FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
$row = mysql_fetch_assoc($request);

if(!empty($row['ID_ATTACH']))
$ava_url = $scripturl . '?action=dlattach;attach='. $row['ID_ATTACH'] .';type=avatar';
elseif(!empty($row['avatar']))
{
if(stristr($row['avatar'], 'http://') === FALSE)
$ava_url = $modSettings['avatar_url'] .'/'. $row['avatar'];
else
$ava_url = $row['avatar'];
}
mysql_free_result($request);
if(isset($ava_url))
echo '<img src="'. $ava_url .'" alt="" border="0" />';
}


Replace the last line with ...

if(isset($ava_url))
echo '<div style="text-align:center;"><img src="'. $ava_url .'" alt="" border="0" /><br />' .$context['common_stats']['latest_member']['link']. '</div>';


Fel

This website is proudly hosted on Crocweb Cloud Website Hosting.