View Full Version : Profile Pic used on other vBulletin pages
Warlord
11-30-2008, 04:17 PM
Does anyone know how to display the profile picture in other places on your forums? I've added the code from the modifyprofilepic template to my usercp_shell template, but it only works when you load the Edit Profile Pic page.
I'd like it to load in usercp_shell.
I'm guessing that it is calling for some variable(s) that usercp.php doesn't load but profile.php does. I've looked through profile.php for the code to load these variables but have come up short. I'd be grateful to anyone who knows how I might go about doing this.
Warlord
12-01-2008, 10:06 PM
Perhaps I should put the code in here for people to look at.
I added this code to usercp_shell:
<tr class="alt2">
<if condition="!$show['profilepic']">
<td class="alt1" style="border:1px inset; padding:$stylevar[cellpadding]px">
<span class="smallfont">$vbphrase[no_profile_picture]</span>
</td>
<else />
<td class="smallfont">
<img src="$bbuserinfo[profileurl]" alt="$vbphrase[your_profile_picture]" border="0" />
</td>
</if>
</tr>
Problem #1: The if statement never comes true, even if the user has a profile picture uploaded. (It does come true when you load the edit profile picture page tho and functions correctly.)
Problem #2: I temporarily removed the surrounding IF statement from the code that calls the profile picture to see if it the IF statement was the only problem, but sadly it is not. The variable provides no ouput even without being wrapped in the IF statement.
Anyone have any suggestions?
--------------- Added 1228186250 at 1228186250 ---------------
Nevermind, I got it.
For anyone who's interested in doing this...
Create a new plug in called Profile Pic in User CP and set it to the usercp_start hook with the following code:
// ########################## EDIT PROFILE PICTURE ############################
// ################################################## ##########################
{
($hook = vBulletinHook::fetch_hook('profile_editprofilepic' )) ? eval($hook) : false;
if ($vbulletin->options['profilepicenabled'] AND ($permissions['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canprofilepic']))
{
if ($profilepic = $db->query_first("
SELECT userid, dateline, height, width
FROM " . TABLE_PREFIX . "customprofilepic
WHERE userid = " . $vbulletin->userinfo['userid']
))
{
if ($vbulletin->options['usefileavatar'])
{
$vbulletin->userinfo['profileurl'] = $vbulletin->options['profilepicurl'] . '/profilepic' . $vbulletin->userinfo['userid'] . '_' . $vbulletin->userinfo['profilepicrevision'] . '.gif';
}
else
{
$vbulletin->userinfo['profileurl'] = 'image.php?' . $vbulletin->session->vars['sessionurl'] . 'u=' . $vbulletin->userinfo['userid'] . "&dateline=$profilepic[dateline]&type=profile";
}
if ($profilepic['width'] AND $profilepic['height'])
{
$vbulletin->userinfo['profileurl'] .= "\" width=\"$profilepic[width]\" height=\"$profilepic[height]";
}
$show['profilepic'] = true;
}
$permissions['profilepicmaxsize'] = vb_number_format($permissions['profilepicmaxsize'], 1, true);
$maxnote = '';
if ($permissions['profilepicmaxsize'] AND ($permissions['profilepicmaxwidth'] OR $permissions['profilepicmaxheight']))
{
$maxnote = construct_phrase($vbphrase['note_maximum_size_x_y_or_z'], $permissions['profilepicmaxwidth'], $permissions['profilepicmaxheight'], $permissions['profilepicmaxsize']);
}
else if ($permissions['profilepicmaxsize'])
{
$maxnote = construct_phrase($vbphrase['note_maximum_size_x'], $permissions['profilepicmaxsize']);
}
else if ($permissions['profilepicmaxwidth'] OR $permissions['profilepicmaxheight'])
{
$maxnote = construct_phrase($vbphrase['note_maximum_size_x_y_pixels'], $permissions['profilepicmaxwidth'], $permissions['profilepicmaxheight']);
}
$show['maxnote'] = (!empty($maxnote)) ? true : false;
$show['profilepic_url'] = (ini_get('allow_url_fopen') != 0 OR function_exists('curl_init'));
// draw cp nav bar
construct_usercp_nav('profilepic');
$navbits[''] = $vbphrase['edit_profile_picture'];
$templatename = 'modifyprofilepic';
}
else
{
print_no_permission();
}
}
Then just add the code from the above post in template usercp_shell where ever you'd like it to appear.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.