View Full Version : Custom page showing profile pic, need "wildcard" reference for pic changes
bzcomputers
01-25-2013, 08:51 AM
I currently have a custom page showing user profile pics.
The code below is currently calling up the images without issue from the file system.
$url = sprintf('customprofilepics/profilepic%d_1.gif', $registration['Registration']['user_id']);
The issue I'm going to have is, as soon as someone updates their profile pic it will no longer show because it is hardcoded currently to "1". I need to replace the "1" with a wildcard so that it will find an image no matter how many times it's updated.
I'm just not experienced enough with php to know how to place a wildcard in that statement.
Any help would be appreciated, thanks.
I think you want profilepicrevision from the user info. So something like:
$url = sprintf('customprofilepics/profilepic%d_%d.gif', $registration['Registration']['user_id'], $userinfo['profilepicrevision']);
but I don't know if there's any $userinfo available so I'd be surprised if that worked as is.
bzcomputers
01-25-2013, 07:29 PM
I got this to pick up the correct revision #:
$url = sprintf('customprofilepics/profilepic%d_%d.gif', $registration['Registration']['user_id'], $vbulletin->userinfo['profilepicrevision']);
..but then it uses the correct revision for the first user for all the remaining users on the page. So if the first user returned is on revision 3 and the rest are still on 1 it uses 3 for all.
Yeah, $vbulletin->userinfo will always be you (or whoever's logged in). You need to get the profilepicrevision for each user in that $registration array. You could just do a query of the user table for each user, but if there's already a query being done to get that other info you might be able to add on to that (or maybe you've already got it in memory somewhere).
bzcomputers
01-25-2013, 08:39 PM
Here is the query above it:
<td>
<?php
if ($GLOBALS['vbulletin']->db->query_first(sprintf('SELECT dateline FROM %1$scustomprofilepic WHERE userid = %2$d', TABLE_PREFIX, RollCalls::$vB_User_Id)) != null && $registration['Registration']['profile_picture'] && $registration['Registration']['user_id']) {
$url = sprintf('customprofilepics/profilepic%d_1.gif', $registration['Registration']['user_id']);
} else {
$url = 'images/misc/unknown.gif';
}
echo $this->Html->image("{$GLOBALS['vbulletin']->options['bburl']}/{$url}");
?>
</td>
Maybe try this change (replaces the similar block of code from what you posted above):
if (($ppic = $GLOBALS['vbulletin']->db->query_first(sprintf('SELECT dateline, profilepicrevision FROM %1$scustomprofilepic AS customprofilepic LEFT JOIN %1$suser USING(userid) WHERE customprofilepic.userid = %2$d', TABLE_PREFIX, RollCalls::$vB_User_Id))) != null && $registration['Registration']['profile_picture'] && $registration['Registration']['user_id']) {
$url = sprintf('customprofilepics/profilepic%d_%d.gif', $registration['Registration']['user_id'], $ppic['profilepicrevision']);
} else {
$url = 'images/misc/unknown.gif';
}
bzcomputers
01-25-2013, 11:27 PM
Thanks, but that didn't do it, still trying...
What did happen? Did you get an error, or can you see what filename it was trying to load?
bzcomputers
01-26-2013, 05:29 AM
It was returning a "0" for all pic revisions.
Examples:
/customprofilepics/profilepic1_0.gif
/customprofilepics/profilepic48_0.gif
Oh right - I had a close paren in the wrong place. I fixed the above code so I think it should work now.
bzcomputers
01-26-2013, 02:30 PM
The updated code has gone back to showing the revision # for whomever is logged in at every instance.
bzcomputers
01-28-2013, 12:17 AM
any other suggestions?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.