MyBB Community Forums

Full Version: MyBB code question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How can I get the UID of a user from their username?
How can I get the UID of a user from their username?
This little code will do it:
{$mybb->user['uid']}
I need a function like so:

function uid_to_username($username)
{
//find username using user id
return $uid
}
This will grab the uid if their username is correct. I'm assuming you know how to grab their username, if not just let me know and i'll edit it Wink
global $db;
$qry = $db->query("SELECT uid FROM ".TABLE_PREFIX."users WHERE username = '".$usernamevar."'");
Thank you very much!
NP, feel free to +rep me Wink
Simpler way.

$user = get_user($uid);
echo $user['username']
Ah, much simpler. Thank you.
No problem. Smile
Pages: 1 2