Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2014, 05:36 PM
Kel0G Kel0G is offline
 
Join Date: Apr 2014
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 05-13-2014, 06:05 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Writing to it how?
Reply With Quote
  #3  
Old 05-13-2014, 07:38 PM
vBNinja's Avatar
vBNinja vBNinja is offline
 
Join Date: May 2011
Location: USA
Posts: 239
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

just add a column to the user database table
then you can access that column with the $vbulletin->userinfo array
Reply With Quote
  #4  
Old 05-13-2014, 07:40 PM
Kel0G Kel0G is offline
 
Join Date: Apr 2014
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 05-13-2014, 08:13 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You want to update the users usergroupid? in the database, or on the page load?
Reply With Quote
  #6  
Old 05-13-2014, 08:23 PM
Kel0G Kel0G is offline
 
Join Date: Apr 2014
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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).
Reply With Quote
  #7  
Old 05-13-2014, 08:32 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!)
Reply With Quote
Благодарность от:
kehindelawal
  #8  
Old 05-13-2014, 08:42 PM
Kel0G Kel0G is offline
 
Join Date: Apr 2014
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 05-14-2014, 05:20 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Whoops! UPDATE for updating the table. ALTER for changing the table itself.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:37 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03906 seconds
  • Memory Usage 2,244KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (1)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete