MyBB Community Forums
Grab User's UID with jS? - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: Grab User's UID with jS? (/thread-137438.html)



Grab User's UID with jS? - iHydra - 2013-04-09

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


RE: Grab User's UID with jS? - Eric - 2013-04-09

<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)


RE: Grab User's UID with jS? - iHydra - 2013-04-09

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.