Grab User's UID with jS?
#1
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
Reply
#2
<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)
Reply
#3
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)