vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=262)
-   -   How to get userid of members by php? (https://vborg.vbsupport.ru/showthread.php?t=322784)

hienntp 06-06-2016 08:03 AM

How to get userid of members by php?
 
hello,
How to get userid of members by php? I use vbulletin 5.
Thanks!

Replicant 06-06-2016 02:19 PM

Can you elaborate more on what you are trying to do?

hienntp 06-10-2016 12:15 AM

I want to get userid of members when logging in forum.
get userid vbulletin 4:
$user = $vbulletin->userinfo;
echo $user['usertid'];

Replicant 06-10-2016 03:01 AM

The vbulletin object is still available in vb5. The code you show should work.
For getting userid in scripts, this works for me.

$uid=$vbulletin->userinfo['userid'];
echo $uid;

hienntp 06-10-2016 07:56 AM

I added the code into file account.php
$uid=$vbulletin->userinfo['userid'];
echo $uid;

But error:

Notice: Undefined variable: vbulletin in /var/www/forum.whitehat.vn/Soccer/account.php on line 128
Notice: Trying to get property of non-object in /var/www/forum.whitehat.vn/Soccer/account.php on line 128

Replicant 06-10-2016 11:43 AM

Account.php is not a core file. You'll need to start up the vbulletin backend to get a result. This example assumes the account.php file is inside your forum root directory. This is a bare bones example.

<?php
require_once('./includes/vb5/autoloader.php');
$vbpath = '.';
vB5_Autoloader::register($vbpath);
vB5_Frontend_Application::init('config.php');

$uid=$vbulletin->userinfo['userid'];
echo $uid;

hienntp 06-10-2016 12:19 PM

I edit:
require_once('/var/www/forum.whitehat.vn/includes/vb5/autoloader.php');
$vbpath = '.';
vB5_Autoloader::register($vbpath);
vB5_Frontend_Application::init('config.php');
$uid=$vbulletin->userinfo['userid'];
echo $uid;

But error:
Class 'vB5_Frontend_Application' not found

Replicant 06-10-2016 11:24 PM

Try using your full system path for $vbpath. It's not finding the Class because it's not looking in the right location. Is you account.php file in the /var/www/forum.whitehat.vn directory?

hienntp 06-13-2016 12:34 AM

I have edit $vbpath = '/var/www/forum.whitehat.vn/.'; and it works.
Thanks!


All times are GMT. The time now is 01:57 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.01924 seconds
  • Memory Usage 1,713KB
  • 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)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