[REQUEST] Show name MyCode
#1
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
Reply
#2
You can find something similar here. It's for RC4, but It'll work for 1.0 too.
http://mods.mybboard.com/view.php?did=7
Reply
#3
meh... I made one anyway. Just upload the attachment to your plugin folder and activate it


Attached Files
.php   namebbcode.php (Size: 1.29 KB / Downloads: 113)
Reply
#4
Lol you forgot to change the the plugin name/version at the top of my plugin file Toungue

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 Wink
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
Reply
#5
ahhh...thanks Wink I didnt know how to replace text in a post so I used your google code Wink
Reply
#6
You can probably get away with
str_replace("[name]", $username, $message);

I think str_replace is faster than preg_replace...
Dennis Tsang
Former MyBB Team Member
Web: http://dennistt.net
Reply
#7
your right Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)