Good document markup helps, looks like you were missing a ; on your line 7, I added it, formatted it, and moved the require_once inside of the conditional.
The error gone but in sent folder all avatars is (unknown.gif)
see the screen-shot for sent folder
In inbox, the username shown under the PM title is for the person who sent the PM for me. so I want to show the avatar for that username (who sent the PM for me)
In sent folder, the username shown under the PM title is for the person who will receive my PM, so I want to show the avatar for that username (who will receive my PM)
The error gone but in sent folder all avatars is (unknown.gif)
see the screen-shot for sent folder
That's my fault. After all that, it turns out my solution is wrong. There is actually an array of "to" users, so I don't know what you would want to display if the message has been sent to more than one user. But a better way to check if you are viewing the Sent folder is to check the folder id, so you could do something like this:
PHP Code:
if (THIS_SCRIPT == 'private') { require_once('./includes/functions_user.php'); if ($folderid != -1) { $avid = $pm['fromuserid']; } else { // This is the Sent folder, so find the first userid // that is not the viewing user, checking first 'cc' // then 'bcc' users. $tousers = unserialize($pm['touserarray']); if (!empty($tousers)) { $toids = (empty($tousers['cc']) ? array() : $tousers['cc']); if (!empty($tousers['bcc'])) { $toids = array_merge($toids, $tousers['bcc']); } foreach ($toids AS $id => $username) { if ($id != $vbulletin->userinfo['userid']) { $avid = $id; break; } } } } $pm[avatarurl] = fetch_avatar_url($avid); if (!$pm[avatarurl]) { $pm[avatarurl] = $stylevar['imgdir_misc'] . 'images/misc/unknown.gif'; } else { $pm[avatarurl] = $vbulletin->options['bburl'] . '/' . $pm[avatarurl][0]; } }
That's my fault. After all that, it turns out my solution is wrong. There is actually an array of "to" users, so I don't know what you would want to display if the message has been sent to more than one user. But a better way to check if you are viewing the Sent folder is to check the folder id, so you could do something like this:
PHP Code:
if (THIS_SCRIPT == 'private')
{
require_once('./includes/functions_user.php');
if ($folderid != -1)
{
$avid = $pm['fromuserid'];
}
else
{
// This is the Sent folder, so find the first userid
// that is not the viewing user, checking first 'cc'
// then 'bcc' users.
$tousers = unserialize($pm['touserarray']);
if (!empty($tousers))
{
$toids = (empty($tousers['cc']) ? array() : $tousers['cc']);
if (!empty($tousers['bcc']))
{
$toids = array_merge($toids, $tousers['bcc']);
}
foreach ($toids AS $id => $username)
{
if ($id != $vbulletin->userinfo['userid'])
{
$avid = $id;
break;
}
}
}
}
$pm[avatarurl] = fetch_avatar_url($avid);
if (!$pm[avatarurl])
{
$pm[avatarurl] = $stylevar['imgdir_misc'] . 'images/misc/unknown.gif';
}
else
{
$pm[avatarurl] = $vbulletin->options['bburl'] . '/' . $pm[avatarurl][0];
}
}
Wow :up: working perfect as a charm
Thanks dear
Can I use your code in my mod that I will release to the public here in vb.org?
Can I use your code in my mod that I will release to the public here in vb.org?
You can use that code in your mod. But you might want to come up with some way to indicate if a message was sent to more than one user. (or not, if it doesn't bother you ).
You can use that code in your mod. But you might want to come up with some way to indicate if a message was sent to more than one user. (or not, if it doesn't bother you ).
Although it is not bothering me, I will try to find a solution because I want to release it to the public.
Thanks Kevin
You must 'Like' someone else's post before liking any more by kh99.