Grab User's UID with jS?
I'm working on a userscript and trying to grab the user's UID.

I currently have this, but no luck.

var uid = "<?php echo {$mybb->user['uid']} ?>";
elmTextarea.value = elmTextarea.value.replace(re,"[url=" + uid + "][color=green][b]PM ME[/b][/color][/url]");

Is it possible?

<script type="text/javascript">
var uid = {$mybb->user['uid']};
var yourElement = document.getElementById('yourElement');
yourElement.innerHTML = "[url=" + uid + "][color=green][b]PM ME[/b][/color][/url]";

That should do what you're looking for. ^.^

(err, that will work in templates. As for a plugin, you could probably use the PHP variable equivalent you posted)
Well I want to be using the replace method so when someone types in


It will trigger a replacement and add the PM link but then grab the UID from MyBB before inserting the full thing.

because I have

re = /\[pm\]/gi;

that I didn't add in OP.

Forum Jump:

Users browsing this thread: 1 Guest(s)