For example, if you typed:
[name]
It would display whoever is viewing the thread's name.
ex: Chris-h11 If I was viewing the thread
or BillyBobJoe if someone named BillyBobJoe was viewing the thread
meh... I made one anyway. Just upload the attachment to your plugin folder and activate it
Lol you forgot to change the the plugin name/version at the top of my plugin file
You can slim this down:
function namebbcode_run($message)
{
global $db, $mybb;
if($mybb->user['uid'] == 0)
{
$username[1] = "Guest";
}
else
{
$username = mysql_fetch_row($db->query("SELECT * FROM ".TABLE_PREFIX."users WHERE uid = '".$mybb->user['uid']."' LIMIT 1"));
}
return preg_replace("#\[name\]#sie", $username[1], $message);
}
To
function namebbcode_run($message)
{
global $mybb;
$username = ($mybb->user['uid'] > 0) ? $mybb->user['username'] : 'Guest';
return preg_replace("#\[name\]#i", $username, $message);
}
Saves a query
ahhh...thanks
I didnt know how to replace text in a post so I used your google code
You can probably get away with
str_replace("[name]", $username, $message);
I think str_replace is faster than preg_replace...