PDA

View Full Version : [hook] grabbing userid


Dr.CustUmz
02-14-2015, 09:34 AM
first what im trying to do: I want to be able to grab the userid and show it in the forumhome_lastpostby template.

what ive got so far: i have created a plugin at forumbit_display:
$username = $lastpostinfo[lastposter];
$lastposter = $vbulletin->db->query_first("SELECT userid FROM ". TABLE_PREFIX ."user WHERE username = \"$username\"");

so its grabbing the last posters username, and looking for their id in the DB then displaying when i use
$lastposter[userid]

the problem is, it's not quite working =(

i get a result that shows on one of my forums, but the rest are blank.
*note i have removed everything from the lastpostby template and only have $lastposter[userid]*
https://vborg.vbsupport.ru/attachment.php?attachmentid=151872&stc=1&d=1423913520
dont mind the theme, just something im finally bringing to life, but where i have circled their should be userids, topmost should be a 2 and the other missing one a 1 for my id.

*note 2* this way does work on the forumbit templates properly but i would much rather have it in the lastpostby template
so its a matter of what hook im assuming, and i've cycled through a majority of them and none seem to do it =/

kh99
02-14-2015, 10:48 AM
Hmm...I don't know why that isn't working. Maybe you can also display the username to see if that's valid. Also you probably need to use $vbulletin->db->escape_string() on the username in case it contains special characters (although it seems unlikely that that's the problem here).

I think you might be able to do this without a query. I guess lastpostinfo is built instead of getting it directly from $forum because categories want to be able to display the latest info from a child? But all the poster info including the userid is already in the $vbulletin->forumcache[] array, so if you searched that array (or the current forum and it's children) for $vbulletin->forumcache[X]['lastposter'] == $lastpostinfo[lastposter], then you could just use $vbulletin->forumcache[X]['lastposterid'].

But I guess that doesn't necessarily fix the problem you're having.

Dr.CustUmz
02-14-2015, 12:37 PM
i actually ended up leaving this as is and worked with it, i guess i can handle it being in the forumbits lol.

but i moved on to phase 2 of this and i actually got help with that part from another one of your posts, but somethings wrong again lol, i made anther post over here
https://vborg.vbsupport.ru/showthread.php?t=317330