Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2012, 11:02 PM
PleaseHelp PleaseHelp is offline
 
Join Date: Jan 2012
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default DataManager: Problem changing username before deleting user

Hello,

We want to change the username of all users we delete prior to their deletion so that all their "Guest" posts contain the new username.

We have the DataManager code for both changing the username and deleting a user, and each works fine independently. The change username code correctly changes the username of the user and the change is correctly reflected in all of that user's posts and threads. Likewise, the delete user completely deletes the user and changes all the user's posts to the "Guest" title.

However, when run together, one right after the other, they cause a problem. The code below does NOT change the username of all the posts of the user, even though it does change the user's username and then deletes him, leaving all his posts with his original username (not the new username):

PHP Code:
include("global.php");

$newusername 'DeletedUser1';

//change username
$vbulletin->GPC['userid'] = $userid;
$userdm =& datamanager_init('User'$vbulletinERRTYPE_CP);
$userdm->adminoverride true;
$userinfo fetch_userinfo($vbulletin->GPC['userid']);
$userdm->set_existing($userinfo);
$userdm->set('username'$newusername);  //usergroupid
$changeuser $userdm->save();  //returns 1 on success
echo $changeuser;
unset(
$userdm);
    
//delete user
if ($changeuser == 1) {
      
$vbulletin->GPC['userid'] = $userid;
      
$userinfo fetch_userinfo($userid);
      
$userdm =& datamanager_init('User'$vbulletinERRTYPE_CP);
      
$userdm->set_existing($userinfo);
      
$deleteuser $userdm->delete();
      echo 
$deleteuser //returns 1 on success


Both $changeuser and $deleteuser return 1, so they are executing correctly. However, as mentioned above, when the script is done deleting the user, all his deleted posts contain the original username, not the new username changed in the script.

However, if we split the code above into two separate scripts (one to change the username and the other to delete the user), and run one after the other, then it works and correctly changes the username of all the user's posts such that after he is deleted, it displays the new username in all his posts (together with the "Guest" title).

This tells us that when it is run together, something either in the SESSION vars or some GLOBAL var is not being updated with the new username, so that when the delete part comes along, it still has the old username in memory and that's why it is not changing the username in the posts (or something to that effect). (We should add that it DOES change the username in the threads, but NOT the posts, which is very strange.)

So how can we resolve this so we don't have to run it as 2 scripts? Is there some way of "refreshing" whatever variable might be causing this?

Thanks!
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 11:03 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.04025 seconds
  • Memory Usage 2,215KB
  • 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)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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