Who Referred?
This is a simple plugin that will show the username of the referring member in a user's profile. The username is clickable but NOT styled.
View mod on mods site :
Who Refer
Nice idea for a plugin.
This could be added here to show how many people used
Google as their referrer on the community forums.
I there, I went ahead and used your idea to implement it into the MyProfile plugin:
https://github.com/medbenji/MyProfile/pull/49
BTW there seems to be a HTML syntax error in your code
Also,it seems you use a while loop whereas the maximum referrers per user is one?
Thanks!
HtML Errors oh no
I will look into the loop, but I don't really see the issue with using a while? What would you use in this situation?
Maybe this?
if($whorefer_count > 0)
{
$referral = $db->fetch_array($query);
$whorefer_referrals .= build_profile_link($referral['refername'], $referral['referid']);
}
Yes, since only one result is expected something like the following should work.:
$query = $db->query("
SELECT u.uid, ru.uid AS referid, u.referrer, ru.username AS refername
FROM ".TABLE_PREFIX."users u
LEFT JOIN ".TABLE_PREFIX."users ru ON (ru.uid=u.referrer)
WHERE u.referrer > '0'
AND u.uid = '".intval($GLOBALS['uid'])."'
LIMIT 0,1
");
$referral = $db->fetch_array($query);
if($referral['referid'])
{
$referral['refername'] = htmlspecialchars_uni($referral['refername']);
(Note I only added a limit of 1 to the query to be sure. Probably not necessary.)
Though somebody mentioned "Google" as a referrer but IIRC that is not possible, is't?
Quote:but I don't really see the issue with using a while?
It is slower when you already know it can only be one result.
Oh, I think you already updated your plugin.
Is this all fixed now can we use it on our site?
It wasn't broken - the plugin creates a template that you can edit as you wish so the small html error was easily fixable; the use of a while was not WRONG exactly - just not what Omar likes
If it was that crap why would he use it in his own plugin?
Checkout stable version from mods site
Yes the plugin was never broken really, it was me me :p you can say haha
Yea, its a long time since I used tables code for display so I have to keep looking up the syntax