I created a function I was wondering if I could have someone look it over. It pretty much takes the text in a post and looks for a username, and if there is one, it will mark it up as url and usergroup color. Anyway heres the code.
PHP Code:
function convert_username_to_url($text1)
{
global $vbulletin;
if ($vbulletin->$bbuserinfo[userid] > 0)
{
$userSearchQuery = $vbulletin->db->query_read("
SELECT userid, usergroupid, displaygroupid, username
FROM' . TABLE_PREFIX . 'user
");
While ($customuser = $vbulletin->db->fetch_array($userSearchQuery))
{
fetch_musername($customuser);
$userSearch = array($customuser[username]);
$userReplace = '<a href="member.php?' . $vbulletin->session->vars['sessionurl'] . "u=$customuser[userid]\">$customuser[musername]</a>";
}
}
$text = str_replace($userSearch, $userReplace, $text1);
return $text;
}
Again if you could take a look that would be awesome. I know html, I'm trying to learn php. Thanks