Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2010, 10:05 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Possible to know UserID (pretemplate) in php to load content. [] - new question

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}
Reply With Quote
  #2  
Old 01-02-2010, 10:48 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

erm, sorry to state the obvious but:
PHP Code:
$bbuserinfo['userid'
I'm not sure if i'm understanding you, but the above is the PHP equivalent to the template variable you posted.
Reply With Quote
  #3  
Old 01-03-2010, 08:45 AM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.

PHP Code:
$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

PHP Code:
$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..
Reply With Quote
  #4  
Old 01-03-2010, 09:00 AM
ForumsMods ForumsMods is offline
 
Join Date: Aug 2007
Location: Argentina
Posts: 667
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Use:
PHP Code:
$currentuser $vbulletin->userinfo['userid']; 
Reply With Quote
  #5  
Old 01-03-2010, 09:02 AM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you so much vBs !!!

3x cheers for you.
Reply With Quote
  #6  
Old 01-13-2010, 09:46 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vB Style View Post
Use:
PHP Code:
$currentuser $vbulletin->userinfo['userid']; 
next step, what about usergroup ?

userinfo['usergroup'] does nada, zip,, zero
Reply With Quote
  #7  
Old 01-13-2010, 09:52 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 01-13-2010, 09:58 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
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

PHP Code:
$usergroups htmlspecialchars_uni($vbulletin->options['galusergrp']); 
$usergroup preg_split('/[\s,]+/'$usergroups ); 

$currentuser $vbulletin->userinfo[usergroupid]; 

if (
$currentuser $usergroup)
{

but its always true.
Reply With Quote
  #9  
Old 01-13-2010, 10:45 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
PHP Code:
if (in_array($currentuser, array($usergroup))) 
I think.... I hate playing with arrays.
Reply With Quote
  #10  
Old 01-13-2010, 11:04 PM
Vaupell's Avatar
Vaupell Vaupell is offline
 
Join Date: Apr 2008
Location: Esbjerg, Denmark
Posts: 1,036
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

think im gonna drop the settings, and go old school and do a
prober php file and a database table.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:45 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04542 seconds
  • Memory Usage 2,264KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete