PDA

View Full Version : Showing username from ID


TheFakeEscape
01-26-2010, 01:44 PM
Hey,

I'm doing some site integration and I'm building a comments system, obviously it's using the vBulletin database for the users.

Example:
1 - Bob
2 - Bill

Bob is browsing the website, the below two lines will show his user ID or his Username
$vbulletin->userinfo['userid']; This displays: 1
$vbulletin->userinfo['username']; This displays: Bob

However, when Bill views the website it'll show his name instead of Bob. I thought the following would work, and show any username from the ID I put in
$vbulletin->userinfo['1'];
I want something like this, to show 'Bob' as he's user '1'

Obviously it doesn't work, does anyone know how to display a Username from an ID?

James Birkett
01-26-2010, 01:53 PM
You would probably have to do an SQL query that searches the userid and returns the name.

Create a function or something, unless someone else has another method.

TheFakeEscape
01-26-2010, 02:00 PM
Actually managed to dig it out of the vB3 section.


$info = fetch_userinfo($userid);
$username=$info["username"];
echo $username;


Cheers. :)