MyBB Community Forums
[For 1.8] Who Referred ? - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Releases (https://community.mybb.com/forum-102.html)
+---- Thread: [For 1.8] Who Referred ? (/thread-163440.html)

Pages: 1 2 3


Who Referred ? - Leefish - 2014-11-27

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


RE: Who Referred ? - Darth Apple - 2014-11-27

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


RE: Who Referred ? - Omar G. - 2014-11-30

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!


RE: Who Referred ? - Leefish - 2014-11-30

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']);
	}



RE: Who Referred ? - Omar G. - 2014-12-01

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.


RE: Who Referred ? - Omar G. - 2014-12-01

Oh, I think you already updated your plugin. Toungue


RE: Who Referred ? - ytt - 2014-12-01

Is this all fixed now can we use it on our site?


RE: Who Referred ? - Leefish - 2014-12-02

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


RE: Who Referred ? - Omar G. - 2014-12-02

Yes the plugin was never broken really, it was me me :p you can say haha


RE: Who Referred ? - Leefish - 2014-12-02

Yea, its a long time since I used tables code for display so I have to keep looking up the syntax Big Grin