1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.1 Removing all followers and followed on all users

Discussion in 'Troubleshooting and Problems' started by Ingenious, Feb 15, 2012.

  1. Ingenious

    Ingenious Well-Known Member

    Following an import from vB is there any easy way (or an SQL query) I can run to remove every user's followed and followers from their profiles please?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Run these queries:

    UPDATE xf_user_profile
    SET following = '';
    TRUNCATE TABLE xf_user_follow;
    Ingenious likes this.
  3. Ingenious

    Ingenious Well-Known Member

    Just done that Jake and it's fixed it nicely - all the imported profiles are followed/follows free :) Thanks!
  4. Bellinis

    Bellinis Active Member

    How do I remove all followers and following for a particular user (which passed away)?

  5. Chris D

    Chris D XenForo Developer Staff Member

    I think it would be this SQL query:
    DELETE FROM `xf_user_follow` WHERE `user_id` = 1 OR `follow_user_id` = 1
    Where 1 is the user ID of the person who passed away.

    But I see Jake has referenced the xf_user_profile table - that may be involved too.

    I would wait for someone else to verify my answer, though, before running mine just in case there's some sort of dependency I'm not aware of.

    In my testing, my query has worked, but I don't want to miss anything out.
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yorick's query will work for the normalized data. But with selective removals like this you will need to rebuild the denormalized data in xf_user_profile.following which can't be done with a simple query. A custom script is required.
    Yorick likes this.
  7. Bellinis

    Bellinis Active Member

    And how about only removing the people this particular user is following?
  8. Chris D

    Chris D XenForo Developer Staff Member

    My query does that.

    It removes the rows where user 1 is following or user 1 is followed.

    But I'm concerned about Jake's comments. I'd want to ensure you did this properly, but unfortunately I don't know how to achieve what Jake mentions beyond my simple query.

Share This Page