Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

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:

  1. Is there an easier way to do this without querying the database manually?
  2. The method I have described, am I missing any tables or fields?

Thanks!

Comments

  • Options

    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

    There was an error rendering this rich post.

  • Options
    hgtonighthgtonight ∞ · New Moderator

    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, and gdn_userrole.

    Skip gdn_session and gdn_spammer. I am not sure about gdn_userauthentication.

    Always perform updates on a backup and test.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    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!

  • Options

    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!

    @UnderDog said:
    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

  • Options

    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

    There was an error rendering this rich post.

  • Options

    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!

    @UnderDog said:
    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

  • Options
    hgtonighthgtonight ∞ · New Moderator

    @UnderDog said:
    If You make a plugin out of it, you'll make me a happy UnderDog. (Call it 'MergeUser' or something similar)

    That sounds like an excellent addition to Bulk Edit. I will add it to the feature wishlist.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Options

    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.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    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

    There was an error rendering this rich post.

  • Options

    @UnderDog said:
    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.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    peregrineperegrine MVP
    edited September 2013

    delete dupe :)
    my darn machine is so slow it duplicates comments.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options

    @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 :)

Sign In or Register to comment.