View Full Version : Write to $vbulletin->userinfo
Kel0G
05-13-2014, 05:36 PM
Hey,
I can use $vbulletin->userinfo in a PHP script to read/return a specific value of a field. But what's the command for writing to a specific field?
Zachery
05-13-2014, 06:05 PM
Writing to it how?
vBNinja
05-13-2014, 07:38 PM
just add a column to the user database table
then you can access that column with the $vbulletin->userinfo array
Kel0G
05-13-2014, 07:40 PM
I dont want to access/read from it. I want to write to it through the PHP script and I need to know which vB command should be used for that.
Example (reading):
if (is_member_of($vbulletin->userinfo, 6))
checks if the user is in user group ID of 6. Let's say I want to set the ID for this user instead of reading it, how can this be done?
Zachery
05-13-2014, 08:13 PM
You want to update the users usergroupid? in the database, or on the page load?
Kel0G
05-13-2014, 08:23 PM
The groupID was just an example. I want to edit an entry in the user database in a PHP script I'm calling outside of the forum itself (through a program).
Lynne
05-13-2014, 08:32 PM
If you want to edit and entry *in the database*, then you need to do a query like this (example to set userid to 10 for a user who's username is JoeBlow:
$db->query_write("
UPDATE TABLE " . TABLE_PREFIX . "user
SET userid=10
WHERE username='JoeBlow'
");
http://www.vbulletin.com/docs/html/codestandards_sql_query
(I would NOT change the userids via a query. If you accidentally set the userid to the same as another user, you can really mess things up!)
Kel0G
05-13-2014, 08:42 PM
Of course, the userID was just an example. I've added a custom column for all users which I want edit so the original vB entries stay untouched.
//edit: I've tried your script and it gives me this error:
Fatal error: Call to a member function query_write() on a non-object in ...
//edit2: Changed $db to $vBulletin->db and now when I call the script it opens a "
Quick Setup
Your current site " site of the forum instead of executing the script. Somehow the query does not work.
--------------- Added 1400020894 at 1400020894 ---------------
Okay got it. The problem was that the command "ALTER TABLE" is wrong.
Lynne
05-14-2014, 05:20 PM
Whoops! UPDATE for updating the table. ALTER for changing the table itself.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.