MyBB Community Forums

Full Version: Grab User's UID with jS?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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=http://www.WEBSITE.com/private.php?action=send&uid=" + uid + "][color=green][b]PM ME[/b][/color][/url]");

Is it possible?

Thanks,
Hydra
<script type="text/javascript">
var uid = {$mybb->user['uid']};
var yourElement = document.getElementById('yourElement');
yourElement.innerHTML = "[url=http://www.WEBSITE.com/private.php?action=send&uid=" + uid + "][color=green][b]PM ME[/b][/color][/url]";
</script>

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

[pm]

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.