PDA

View Full Version : Accessing User Info in Plugin Code


manu3569
02-07-2010, 07:08 PM
Hi experts,

I'm currently working on integrating our legacy login system with VBulletin. As such, I've created a new plugin for the 'login_verify_success' hook. Next, I'm trying to set a few session variables that are needed by our other system. I'm running into troubles with accessing all the userinfo fields.

The below code works fine, and the session variable is set correctly. (Works for userid, usergroupid, membergroupid, infractiongroupids, username password, and salt)

$_SESSION['userinfo']['username'] = $vbulletin->userinfo['username'];




When I'm trying to access other values such as email or custom fields, the session variables remains empty. Is my syntax incorrect?

$_SESSION['userinfo']['email'] = $vbulletin->userinfo['email'];


I appreciate any advice. Please let me know if you need additional information.

Thanks!

manu3569
02-10-2010, 09:41 PM
Does anybody know how to access the userinfo data structure in the plugin code section?

kh99
02-10-2010, 10:02 PM
I'm not really familiar with that, but since no one else answered...I grep'ed for 'login_verify_success' and found it in includes/functions_login.php around line 149. Right above that some user data is read from the database, so I guess you could either modify that query to add the fields you need, or else do a similar query in your code. (Because, although I don't know, I'm guessing that at least some of those data items you want are not available unless you somehow get them from the db).

manu3569
02-11-2010, 10:48 AM
Well, the strange thing is if I do a print_r of the vbulletin datastructure, all the fields show up correctly (email, skype, aim, etc). But I can't seem to access them.

As a last resort, I can have an extra query for getting the data I need.

Thanks for your input.

kh99
02-11-2010, 11:20 AM
Hmm...after verify_authentication(), process_login() is called (also in function_login.php), and it looks like maybe that sets up the full $vbulletin->userdata. So maybe you can try moving your plugin to the login_process hook that's called at the end of process_login().

manu3569
02-11-2010, 11:06 PM
Case Close!

@kh99: Thanks a lot for this pointer. That's the right hook and all the data is available.