vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   getting userid on custom page (https://vborg.vbsupport.ru/showthread.php?t=254430)

squishi 11-29-2010 08:48 PM

getting userid on custom page
 
On a custom page that is called periodically with ajax, I would like to check the userid of the user. (I want to compare it with a variable to show a ban button in my chat application).

So this is what I have:
PHP Code:

    chdir('../../forum');
        require_once(
'./global.php');
        echo 
"vbuserinfo: ".$vbulletin->userinfo['userid'];
        die(); 

But vbulletin-userinfo['userid'] is zero ("vbuserinfo: 0").
I am logged in at the forum and global.php is found. I don't understand why it's not working. :confused:

Simon Lloyd 11-30-2010 04:26 AM

You probably need to use this $bbuserinfo[userid]

squishi 11-30-2010 07:48 AM

In a php script? The above code is not in a template.

Lynne 11-30-2010 02:27 PM

My guess would be that global.php is actually not being called. You say you know it's being called - how do you know that?

kh99 11-30-2010 03:09 PM

In ths thread: https://vborg.vbsupport.ru/showthread.php?t=254375 I notice that your $_REQUEST doesn't contain any cookies. To be honest I'm not 100% sure that it should, but the docs say it should. So maybe somehow the cookies aren't being sent with your request and so you're not seen as logged in?

squishi 11-30-2010 11:45 PM

Quote:

Originally Posted by Lynne (Post 2127560)
My guess would be that global.php is actually not being called. You say you know it's being called - how do you know that?

1) The page would show an error message if the file was not found.

2) Vbulletin->userinfo['userid'] is set to 0. I did not set it to zero, so global.php must have set it.

--------------- Added [DATE]1291168079[/DATE] at [TIME]1291168079[/TIME] ---------------

Quote:

Originally Posted by kh99 (Post 2127573)
So maybe somehow the cookies aren't being sent with your request and so you're not seen as logged in?

How would I make the ajax call submit the cookies then? :confused:

kh99 12-01-2010 12:10 AM

Unfortunately I don't know. I always thought they got included automagically based on the domain name you are sending the request to.

Anyone else know?

vvvv Lynne has a good idea.

Lynne 12-01-2010 01:17 AM

Is this in the middle of a function - perhaps you need to make $vbulletin global?

(You wouldn't see errors if you don't have reporting on, so you may want to check your error_logs just in case.)

squishi 12-01-2010 05:55 PM

It's not in a function. I would have received a warning if global was not found.
And the code that I posted above appears exactly the way I posted it. It should work in a function.


All times are GMT. The time now is 02:18 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.00964 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete