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

XF 1.1 Delete banned users with under 5 posts

Discussion in 'XenForo Questions and Support' started by Junior, Jan 22, 2013.

  1. Junior

    Junior Well-Known Member

    What mysql command can I run to delete banned users WITH 5 posts or less?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Deleting users with direct queries is not easily done. There are many joins and updates involved. You need to delete the users through the Admin CP, but there is no mass pruning utility so it's one-by-one.
     
  3. Junior

    Junior Well-Known Member

    I have 2700+ banned users. Is there a fast way to unban users with over 5 posts? Then delete all banned users?

    Maybe move all banned users with over 5 posts to a usergroup?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    There is no mass delete. But banned status is usually sufficient. The software effectively hides banned users for everyone but admins and mods. It's like they don't exist.
     
  5. Junior

    Junior Well-Known Member

    I'd like to unban everyone but a good chunk of them are bots. How about set usergroup id for banned users with under 5 posts?
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  7. Junior

    Junior Well-Known Member

    From that command I put together this. Why would this not work?

    UPDATE xf_user
    SET user_group_id = 10
    WHERE is_banned = 1
    AND message_count >= 5;

    With a little less reasearch and the functions a bit wrong, why not this?

    DELETE xf_user
    WHERE is_banned = 1
    AND message_count >= 5;
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The UPDATE is correct.

    The DELETE is not something you should run. It will delete the xf_user record, but that is only one of many joined tables. For this reason I do not recommend trying to manually delete users with queries. If you want details then refer to the datawriter:

    library/XenForo/DataWriter/User.php

    The _getFields() function names the 5 core user tables. The _postDelete() function names many more.
     

Share This Page