Log in

View Full Version : How to grab Username from inside a Plugin


CoffeeLovesYou
09-23-2012, 08:21 PM
I am using a template with $includedphp in it.
My plugin is as follows (a form which inserts info into the database).. I need it to include their Username but it isn't grabbing anything

ob_start();
?>
<body>
<table border="1">
<tr>
<td align="center">Submit Data</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="submitintodatabasesql.php">
<tr>
<td>Username:</td>
<td><text type="varchar" name="req_username" value="$vbulletin->userinfo['username']" size="50">
</td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit"
name="submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html></center>

<?php
$requestasong = ob_get_contents();
ob_end_clean();

However, the $vbulletin->userinfo['username'] is showing up blank, like this.

https://vborg.vbsupport.ru/external/2012/09/16.png

How do I call the username?

kh99
09-23-2012, 08:41 PM
I don't think there's any html <text> tag. I think you either want <textarea> or <input type="text"...

Edit: Also I don't know if you can put a php variable in there when you're in html mode (outside the <?php ... ?> tags), so you might have to do something like

<?php echo($vbulletin->userinfo['username']); ?>

CoffeeLovesYou
09-23-2012, 09:38 PM
Woohoo, it worked, thank you!! :D
Also, it was <text> because I didn't want them to be able to edit their username. Changed it to input type="text" and added readonly property. You're awesome!