MyBB Community Forums

Full Version: Referrals - SQL Statement - Not understanding.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
MyBB Support,

Alright. I've been looking through my DB to find the referred users, so I could
make a link back to it on the UserCP (so users could view who they referred).

However, in the user's table it only has "referred" and then a number (the number of referrals).

But, if you go to the admin panel, click on a user and then the options tab
it says "show referred members". I went to the

/admin/modules/users.php and looked through that file's source code. And
I found this: (the only thing I could find on the referrals)
if($mybb->input['action'] == "referrers")
{
	$plugins->run_hooks("admin_user_users_referrers");
	
	$page->add_breadcrumb_item($lang->show_referrers);
	$page->output_header($lang->show_referrers);
		
	$sub_tabs['referrers'] = array(
		'title' => $lang->show_referrers,
		'link' => "index.php?module=user-users&action=referrers&uid={$mybb->input['uid']}",
		'description' => $lang->show_referrers_desc
	);
	
	$page->output_nav_tabs($sub_tabs, 'referrers');
	$admin_view['conditions']['referrer'] = $mybb->input['uid'];

if(isset($view['conditions']['referrer'])){
		$view['url'] .= "&action=referrers&uid=".htmlspecialchars($view['conditions']['referrer']);
	}
$popup->add_item($lang->show_referred_users, "index.php?module=user-users&action=referrers&uid={$user['uid']}");

And I didn't see any SQL statements in that either.

So end point how are you calling the statement and getting which user
referred X users? And how can I replicate this, so I can implement into my
own board? (You don't have to actually do it for me, just point in the right
direction).

-Viral.

Well, I'd like to put this to the top. If someone could please take the time to look through this
and answer?

-Viral.
Could I possibly get someone to look at this please?

-Viral.
Just to be sure, you want to show which users X user refferend in his/her profile, right?

MyBB stores not just the amount of reffered users but also the referer of each user.

For example, when you paste "Omar G." in you registration refferer field, one point will be sum to my DB field (referrals) and my UID will be adde to a different field in your DB row (referrer).

With that in mind, you can just fetch somethin like this:
$db->simple_select('users', '*', "referrer='{$memprofile['uid']}'");
Omar,

Lol. Funny enough a few hours after I had posted this and went to work. I was thinking about it
and realized I was either looking in the wrong location for the php code I wanted. Or I could just
use a query to search the entire user row to find what I wanted.

But, as per your post. If it's stored to a row or table. Why can't I find it under say something like
"users_referred" or "mybb_referred". I can see in the user row the _number_ of referred. But not
who referred them. Lol.

But, I think I have an idea in mind on how to achieve this.

-Viral.