View Full Version : Possible to know UserID (pretemplate) in php to load content. [] - new question
Vaupell
01-02-2010, 10:05 PM
Making a costum page, and i got myself stuck..
Got a table with userinformation store in various colums,
and i want it to load so when a use enters that page "from anywhere"
if he is logged in, it shows his stats/content
and for that i would like to do
SELECT * FROM table WHERE userID
but since i dont have a template "first" im not sure how i can check userID
in php, cause i would be missing bbinfo.
proberly crappy explained..
let me know if i need to clear it up a bit..
EDIT : basicly i want this function in PHP
{vb:raw bbuserinfo.userid}
James Birkett
01-02-2010, 10:48 PM
erm, sorry to state the obvious but:
$bbuserinfo['userid']
I'm not sure if i'm understanding you, but the above is the PHP equivalent to the template variable you posted.
Vaupell
01-03-2010, 08:45 AM
I thought so aswell, just cant get it working..
Got a user with the UserID as 1 in the table tableAlpha
The userID's in tableAlpha "Match" userids from vbulletin>user table.
$currentuser=$bbuserinfo['userid'];
// ??? collect current stats
$userstat=$db->query_first("SELECT * FROM " . TABLE_PREFIX . "tableAlpha WHERE UserID='".$currentuser."'");
Shows nothing, howewer if i replace the var currentuser with
$currentuser='1';
then it loads the user fine, so im thinking the $bbuserinfo['userid']; does not return
the correct value
I also tryed entering the bbuserinfo direct into the query with no luck..
ForumsMods
01-03-2010, 09:00 AM
Use:
$currentuser = $vbulletin->userinfo['userid'];
Vaupell
01-03-2010, 09:02 AM
Thank you so much vBs !!!
3x cheers for you. :D
Vaupell
01-13-2010, 09:46 PM
Use:
$currentuser = $vbulletin->userinfo['userid'];
next step, what about usergroup ? :D
userinfo['usergroup'] does nada, zip,, zero :D
Lynne
01-13-2010, 09:52 PM
If you look at the user table in the database, you'll see the field is usergroupid, not just usergroup. And, as the field implies, it is the id not the name of the group.
Vaupell
01-13-2010, 09:58 PM
If you look at the user table in the database, you'll see the field is usergroupid, not just usergroup. And, as the field implies, it is the id not the name of the group.
yeah figured that,, tryed it..
this is what im trying to do
getting the user set groups from settings which is something like 2,5,6,7
$usergroups = htmlspecialchars_uni($vbulletin->options['galusergrp']);
$usergroup = preg_split('/[\s,]+/', $usergroups );
$currentuser = $vbulletin->userinfo[usergroupid];
if ($currentuser = $usergroup)
{
}
but its always true.
Lynne
01-13-2010, 10:45 PM
preg_split returns an array, I believe. So, how can you do a comparison of $currentuser to an array? You would need to do something like:
if (in_array($currentuser, array($usergroup)))
I think.... I hate playing with arrays. :)
Vaupell
01-13-2010, 11:04 PM
yes, usually i would use usergroup control via a admincp.php and a database query,
was just trying something else for a change, to completely remove ekstra upload files,
so it would all just be run on plugins and templates. ;)
then i was looking at bitfield options, but i hate those
haveing to enter each usergroup to enable a product, i prefer just
writeing acces to 2,4,5,6, etc :p
think im gonna drop the settings, and go old school and do a
prober php file and a database table. :D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.