Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 08-29-2012, 09:08 PM
mypcb mypcb is offline
 
Join Date: Aug 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Username change via external system?

We've got vbulletin pretty much integrated into our existing member portal, but I have a quick question re: username changes. When you change an existing user's username via admincp, does it simply update the username field in the user table, or is there more to it?

We have a "change username" function built-in to our existing member portal and we want to update it so that when someone wants to change their username they can just do it there without having to also request that we manually change their vbulletin username ...

I know it's recommended to "update your counters" after changing a username (I assume this refers to the "Update Post Counts" function), which we can initiate programmatically, I'm just wondering if there's anything else we need to or should do besides simply updating the username in the user table?

I assume everything is handled internally based on the user's ID and the username is simply for show next to their posts, etc. so I'm hoping the username isn't found in any of the other 150+ tables that I'm not familiar with.
Reply With Quote
  #2  
Old 08-29-2012, 10:18 PM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't remember where, but i see a mod here that does this
Reply With Quote
  #3  
Old 08-29-2012, 10:44 PM
mypcb mypcb is offline
 
Join Date: Aug 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've seen a mod that allows users to change their own username, but that's not what we want to do. We want to change the username programatically via our existing systems by simply issuing one or more mysql queries to update the necessary table(s).
Reply With Quote
  #4  
Old 08-30-2012, 01:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you look in file includes/class_dm_user.php around line 2363, there's a function update_username() that makes changes to a number of database tables in the event that a username is changed. It's also possible to use the user datamanager (i.e. call that funciton instead of copying the code), but unless your external code is including vbulletin's global.php, it's probably more trouble than it would be worth.
Reply With Quote
  #5  
Old 08-30-2012, 11:26 PM
mypcb mypcb is offline
 
Join Date: Aug 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the reply. Looks like it does update quite a few tables! What would you say is the "best practice" in terms of doing what we want to do? Is it better to call the change_username function, or could we simply do something like this and achieve the same thing? Or would doing this simply update the username in the user table and that's it?

...
$userdm->set_existing($userinfo);
$userdm->set('username', $newusername);
$changeuser = $userdm->save();

And if it's better to call the update_username function, would it just be something like this??

...
$userdm->set_existing($userinfo);
$userdm->update_username($userid, $newusername);
$changeuser = $userdm->save();
Reply With Quote
  #6  
Old 08-31-2012, 06:02 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should follow your first example. I only pointed out update_username() because I thought you might need to change the database directly instead of using the vb datamanager.
Reply With Quote
  #7  
Old 08-31-2012, 01:13 PM
mypcb mypcb is offline
 
Join Date: Aug 2012
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

We can do either, and it looks like using the datamanager will be a little simpler than re-coding 10-15 mysql queries so we'll try that route. Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes

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:09 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.03851 seconds
  • Memory Usage 2,200KB
  • Queries Executed 13 (?)
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
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete