PDA

View Full Version : Cannot get username


LjTiger69
07-15-2011, 10:45 AM
Hello, I'am new in VB4.
I try to create a plugin that add a field in postbit for showing a score from a game. This field is stored in a custom table in db.
This is code for plugin:


$name = $vbulletin->userinfo['username'];
$sql = "SELECT * FROM record WHERE Nome='$name'";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);

if ($row[Record])
{
$template_hook['postbit_userinfo_right_after_posts'] .= '<dt>Score</dt> <dd>' .$row[Record]. '</dd>';
}

Problem is that $name return ""
How can get the username?

nhawk
07-15-2011, 11:03 AM
Try including..

global $vbulletin;

As the first line in your plugin code.

LjTiger69
07-15-2011, 11:08 AM
Thanks now work

--------------- Added 1310732424 at 1310732424 ---------------

Yes now work but $name return my username, not the username of author of thread. How can get the username of author of thread?

--------------- Added 1310734332 at 1310734332 ---------------

OK, I have solved using varible $post[userid]