View Full Version : This piece of code is not working
zmmmzz
07-15-2008, 10:33 PM
Im trying to display a users' avatar in navbar. I add this lines to a plugin in the global_start hook location.
// include backend
require_once('./global.php');
require_once(DIR . '/includes/functions_user.php');
// setup avatar if exists
$avatar = fetch_avatar_url($vbulletin->userinfo['userid']);
if ($avatar != '' AND $vbulletin->options['avatarenabled'])
{
$avatarurl = $avatar[0];
}
Then the html in the navbar template:
<img src="$avatarurl" alt="Your Avatar" border="0" />
The avatar won't display. What am I doing wrong?
MoT3rror
07-16-2008, 01:21 AM
This should be your plugin code. I don't know how that code is not a endless loop if you have that in global_start hook. The global file is already included so you don't need to include it again.
require_once(DIR . '/includes/functions_user.php');
// setup avatar if exists
$avatar = fetch_avatar_url($vbulletin->userinfo['userid']);
if ($avatar != '' AND $vbulletin->options['avatarenabled'])
{
$avatarurl = $avatar[0];
}
Dismounted
07-16-2008, 06:56 AM
Your code in the template should also take into account if the user has no avatar.
<if condition="$avatarurl"><img src="$avatarurl" alt="Your Avatar" border="0" /></if>
zmmmzz
07-17-2008, 04:16 PM
I made the changes but it doesn't seems to work.
I'm using vbulletin's latest version 3.7.2 Patch Level 1. Maybe that's the problem.
noppid
07-17-2008, 04:26 PM
I didn't look at the function you call, but it would seem a string return would be the result, not an array? So get rid of the [0] on $avatar and see what happens.
EDIT: It is an array. I suggest you use...
echo "<pre>";
print_r($avatar);
And see what you are getting in your array key wise and depth wise depending on the avatar you pull and the settings.
Dismounted
07-18-2008, 07:03 AM
I made the changes but it doesn't seems to work.
My changes were for a suggestion to fix a bug ;). You are also going about the wrong way to do this - look in class_core.php (vB_Session class constructor).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.