Update user's activity to a different user
Hello,
I have a request in to a site I am developing using Vanilla Forums to delete a user, but assign that user's activity (conversations, comments, etc) to another user.
My plan is to do this with some queries on these tables:
GDN_Comment
GDN_Conversaiton
GDN_ConversationMessage
GDN_Discussion
I see the fields InsertUserID and UpdateUserID for these tables. My plan is to run queries on the tables:
update GDN_whatever set InsertUserId = newuserid where InsertUserId = olduserid
for InsertUserID and UpdateUserID, to each table.
My question is twofold:
- Is there an easier way to do this without querying the database manually?
- The method I have described, am I missing any tables or fields?
Thanks!
0
Comments
Take a look at the functionalities that are used when you are banning a user. You want to do those exact steps. Maybe even $ User-> Delete() function
Welcome to the community!
What version of Vanilla are you running?
I would perform the update on all tables that list a user id. In 2.0.18.8 default install, that would be:
gdn_activity,gdn_ban,gdn_category,gdn_comment,gdn_conversation,gdn_conversationmessage,gdn_discussion,gdn_draft,gdn_invitation,gdn_log,gdn_photo,gdn_regarding,gdn_tag,gdn_user,gdn_usercategory,gdn_usercomment,gdn_userconversation,gdn_userdiscussion,gdn_usermeta, andgdn_userrole.Skip
gdn_sessionandgdn_spammer. I am not sure aboutgdn_userauthentication.Always perform updates on a backup and test.
I am using version 2.0.18.4. So I can run the update on each of those tables, and that will reassign all activities to the new user, then I can disable the old user account? Thanks for your help!
UnderDog, if you ban a user, is there an option to reassign all of their activity, or are you telling me to look for all the tables those functions reference and update those?
Thanks!
It looks like you have 1 user with 2 usernames, correct? In that case I misunderstood the question and follow hgtonight's excellent advice.
If You make a plugin out of it, you'll make me a happy UnderDog. (Call it 'MergeUser' or something similar)
If you just want to delete the user, follow how a spammer is deleted
Actually, they want to get rid of one admin, and assign any activity that admin may have done to a different admin. My plan was to just query the database due to time constraints, but i will keep in mind the need for a plugin that does this. Thanks!
That sounds like an excellent addition to Bulk Edit. I will add it to the feature wishlist.
To me it would be much cleaner to leave the "admin going" change the username and password and and not comingle the accounts. and reduce the permission level to member for the changed admin.
They probably don't want to see anything related to that old admin name. Makes sense. It's like wiping a virus from your PC
I agree, BUT the activity will be untrue and bizarre, there also could be glitches in meta with dupes, etc, etc. It may work perfectly fine, but I think its looking for trouble. if one admin conversed with the other admin it will also be screwy.
Backup, backup backup.
delete dupe
my darn machine is so slow it duplicates comments.
@peregrine, I agree it is not the best solution, but what they want to achieve is the deletion of the old admin, but any of the instructional or explanatory posts they have made stay in the system where they are, but are reassigned to another admin as if that person posted it in the first place. Anything they want reassigned is just for the general users' benefit, not the admins. I do not believe they communicated on the forum at all.
The plan is to back up all of the tables, change the InsertUserId and UpdateUserId, and test on my local install, then if nothing explodes do it on the live database