View Full Version : How to know does user have avatar or not?
ApplePro
09-29-2007, 01:52 PM
Hello guys,
I'm trying to know about have user avatar or not. I'm looking into userinfo array:
print_r($vbulletin->userinfo);
And I see this in it for both user that has avatar and user that has not:
[avatarid] => 0 [avatarrevision] => 0
In both cases it's 0. :confused:
Dismounted
09-30-2007, 06:18 AM
// 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 (empty($avatar) AND $vbulletin->options['avatarenabled'])
{
// user has no avatar
}
ApplePro
09-30-2007, 09:17 AM
// 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 (empty($avatar) AND $vbulletin->options['avatarenabled'])
{
// user has no avatar
}
Thanks for advice. I've tried it, but I get error message "Database error".
I've changed it little bit. I've used this:
$forumpath2 = "/home/user/forums/";
require_once($forumpath2.'global.php');
require_once($forumpath2.'includes/functions_user.php');
instead of this:
require_once('./global.php');
require_once(DIR . '/includes/functions_user.php');
Dismounted
09-30-2007, 09:20 AM
// change working dir
$curdir = getcwd();
chdir('/home/user/forums');
// 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 (empty($avatar) AND $vbulletin->options['avatarenabled'])
{
// user has no avatar
}
// bring back to proper directory
chdir($curdir);
ApplePro
09-30-2007, 09:32 AM
I've made this work by this adding these lines into login_inc mod:
$file = $forumpath."image.php?u=$userid";
list($width, $height, $type) = getimagesize($file);
if ($width == 1){
//User has no avatar
}
I seems your code doesn't work for me, because I'm using it inside login_inc.php.
But still thanks for your advices.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.