BWG
  • Posts: 72
  • Joined: 19/01/2010
Hi,

Is there a way of removing users in bulk from YAF 2.2.0? What I want to do is delete all user accounts that have been inactive (not visited the forum) for more than X months.

Thanks

BWG
Sponsor
tha_watcha
  • Posts: 4114
  • Joined: 06/03/2010
The only way would be to do it directly via sql


  declare @UserID int

  declare userID cursor for
            select UserID from	[{databaseOwner}].[{objectQualifier}User]
WHERE DATEDIFF(YEAR, LastVisit, GetDate()) >= 5

        open userID

        fetch next from userID into @UserID
        while @@FETCH_STATUS = 0
        begin
            EXEC [{databaseOwner}].[{objectQualifier}user_delete] @UserID
			

            fetch next from userID into @UserID
        end
        close userID
        deallocate userID


this would delete all users that last visit the forum 5 years ago
UserPostedImage
BWG
  • Posts: 72
  • Joined: 19/01/2010
Many thanks for that.

Just one follow up question please. What happens to the posts associated with the user accounts that have been deleted - do the posts remain with a label saying something like "Anonymous user" or are they and all replies to them also deleted?
tha_watcha
  • Posts: 4114
  • Joined: 06/03/2010
Originally Posted by: BWG

Many thanks for that.

Just one follow up question please. What happens to the posts associated with the user accounts that have been deleted - do the posts remain with a label saying something like "Anonymous user" or are they and all replies to them also deleted?



No in that case the messages of the user will not be deleted, the user name will be replaced with the guest user name for all the messages.


UserPostedImage
Users browsing this topic
    Forum Jump  
    • You cannot post new topics in this forum.
    • You cannot reply to topics in this forum.
    • You cannot delete your posts in this forum.
    • You cannot edit your posts in this forum.
    • You cannot create polls in this forum.
    • You cannot vote in polls in this forum.

    About Us

    The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

    Powered by Resharper Donate with PayPal button

    Project Twitter Updates

    Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved