MyBB Community Forums

Full Version: Account Switcher Modifications
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was wondering if anyone is willing to help me make a plugin more suitable for one of my forums.

I want to open a rpg, and one thing about rpgs is that you have many accounts. Therefore, when I found Harest simple account switcher (which no longer exists?), I was very happy. However, it is missing a few pieces that I would like.

I am just learning php and mysql and have been having horrible problems trying to get this code to do what I want.

As my members will have multiple accounts, I would love for you to be able to see which ones a player has. When you go to the players profile I would like there to be a list with all the linked accounts.

For people who are unfamiliar with this plugin, this is how it works. Each username has its own user number (uid). When you link an account to another, it takes the uid of the master account and puts it into a created column called as_uid. Example: The account "Master" has uid of 15. Linked1 once linked with Master will have as_uid be 15.

I need to know a select (or some sort of mysql/php function) to find the uid of each account, match it to all the as_uid that have the same number, then print the username links of all the linked accounts.

I'll give you my code but I have no idea what I am doing so don't expect it to be much help. Thanks.

function accountswitcher_profile() {
	global $db, $mybb, $lang, $templates, $theme, $as_profile, $users; 
	
		$lang->load("accountswitcher");
		
		if($mybb->input['uid'] != '') {
			$uid = intval($mybb->input['uid']);
		} else {
			$uid = $mybb->user['uid'];
		}
	
		$query = $db->simple_select("users", "DISTINCT uid, as_uid", "uid = ".$uid."");
		while($row = $db->fetch_array($query)) {
			$topics .= $row['uid'].",";
		}
		
		// set up participants
		$as_profile_userbit = '';
		$accounts = '';
		$i = 0; 
		$query4 = $db->simple_select("users", "DISTINCT username, uid", "uid = ".$uid."");
		while($as_profile_userbit = $db->fetch_array($query4)) { 
			$i++;
			if($i == 1) { 
				$as_profile_userbit .= '<a href="member.php?action=profile&uid='.$as_profile_userbit['uid'].'">'.$as_profile_userbit['username'].'</a>';  
			} else {  
				$as_profile_userbit .= ', <a href="member.php?action=profile&uid='.$as_profile_userbit['uid'].'">'.$as_profile_userbit['username'].'</a>';
			}
		} 
		// get number of users attached to this account
		$count=$db->fetch_array($db->simple_select("users", "COUNT(as_uid) AS number", "as_uid={$mybb->user['uid']}"));

		
		eval("\$as_profile = \"".$templates->get('as_profile')."\";");