Hello Forums
Im trying to build something that will display the most recent post and the most recently viewed thread of a vbulletin logged-in user in the side bar of a wordpress site.
For most recent post I did it like this:
$u_id = $vbulletin->userinfo['userid'];
$q = mysql_query("SELECT * FROM post WHERE userid = $u_id ORDER BY postid DESC LIMIT 5);
while($r = mysql_fetch_assoc($q)){
//echo blah blah blah blah
}
Question: where do I query the most recently viewed thread…uhmm similar to sitepoint forums? I’m using vbulletin 3.8.4
Thanks…
I don’t think vBulletin records that anywhere in the database. The list of the threads you’ve last viewed is maintained in a cookie in the browser for performance reasons. You’ll have to read that cookie for the IDs then get the thread title from the database.
Thanks DAN , do you have an idea what vbulletin variable is holding that cookie?
You’re going to be reading it in WordPress, right? So how would you access vBulletin variables? I don’t know the answer either way, I don’t use vBulletin.
If the WordPress blog and forum are on the same domain, you can read $_COOKIE[‘bbrecentviewed’] directly.
I have included the global.php of vb in my wordpress index.php so I’m pretty sure all vb variables are active on my wp pages when the user is logged in
<?php
chdir("forums/");
require('./global.php');
chdir("../");
?>
It works when I do this:
if ($vbulletin->userinfo['userid']!=0){
echo '<h1>Welcome Back'.$vbulletin->userinfo['username'].'</h1>';
echo '<a href="/forums/login.php?' . $session[sessionurl] . 'do=logout&logouthash=' . $vbulletin->userinfo['logouthash'] . '">Logout</a>';
} else {
//display log in form here
}
maybe there is a variable for that cookie maybe $vbulletin->cookie or something…
Thanks
Hello Dan $_COOKIE[‘bbrecentviewed’] is empty
if ($vbulletin->userinfo['userid']!=0){
echo $_COOKIE['bbrecentviewed'];
}
Ok I got it
if ($vbulletin->userinfo['userid']!=0){
print_r($_COOKIE);
}
echoes this:
Array ( [bblastvisit] => 1263584427 [comment_author_email_86a9106ae65537651a8e456835b316ab] => -snip the email-
[comment_author_86a9106ae65537651a8e456835b316ab] => stone deft [wp-settings-1] => m2=c&m1=o&m0=o&m5=o&m3=c&m4=o&m6=o&m7=c&m8=o&align=left&m9=c&editor=tinymce [wp-settings-time-1] => 1263464305 [wp-settings-2] => m5=o&m4=c&m9=o&m7=o [bbpassword] => bfb396e7d664ce4a416ffda3ae437d0a [bbuserid] => 2 [bblastactivity] => 0 [wp-settings-time-2] => 1263561229 [bbsessionhash] => 7a25b19c01c86e3021d4ee68a44cbc89 [vbulletin_collapse] => [bbreferrerid] => 0 [bbthreadedmode] => [bbstyleid] => 0 [bblanguageid] => 0 )
I now know the bblastvisit variable how can I use it to query the database…Please bear with me I’m almost there
Thanks
oh bump $_COOKIE [‘bblastvisit’] is a timestamp there is no cookie value for bbrecentviewed
:bawling:
Have you recently viewed posts in that browser?
I have the cookie from this forum we’re talking on. It has 16 IDs in it. Maybe you’re using a different version of vBulletin and it’s been changed.
It’s vb 3.8.4 patch level. I tried viewing some threads, the variable bblastviewd is still not appearing…Whats the $_COOKIE[‘bblastactivity’] for? it’s always set to 0
Haven’t a clue, 0 here too, so it’s not what yer lookin’ for.