vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   Write to $vbulletin->userinfo (https://vborg.vbsupport.ru/showthread.php?t=311329)

Kel0G 05-13-2014 05:36 PM

Write to $vbulletin->userinfo
 
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:
PHP Code:

$db->query_write("
    UPDATE TABLE " 
TABLE_PREFIX "user
    SET userid=10
    WHERE username='JoeBlow'
"
); 


http://www.vbulletin.com/docs/html/c...ards_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:
PHP Code:

Fatal errorCall 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 [DATE]1400020894[/DATE] at [TIME]1400020894[/TIME] ---------------

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.


All times are GMT. The time now is 05:29 AM.

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.01104 seconds
  • Memory Usage 1,726KB
  • 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
  • (2)bbcode_php_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