Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[For 1.8] Who Referred ?
#1
Who Referred?


[Image: preview_23276_1416944696_eefb6d18a62ab46...24ebb0.png]



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
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


Reply
#2
Nice idea for a plugin.

This could be added here to show how many people used Google as their referrer on the community forums. Toungue
Reply
#3
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 Toungue Also,it seems you use a while loop whereas the maximum referrers per user is one?

Thanks!
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#4
HtML Errors oh no Sad

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']);
	}
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


Reply
#5
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.
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#6
Oh, I think you already updated your plugin. Toungue
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#7
Is this all fixed now can we use it on our site?
AdminAds! Free Advertising/Promotion Community
Reply
#8
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 Toungue

If it was that crap why would he use it in his own plugin?

Checkout stable version from mods site
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


Reply
#9
Yes the plugin was never broken really, it was me me :p you can say haha
Soporte en Español

[Image: signature.png]

Discord at omar.gonzalez (Omar G.#6117); Telegram at @omarugc;
Reply
#10
Yea, its a long time since I used tables code for display so I have to keep looking up the syntax Big Grin
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)