Mass User Deletion

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
3/26/2011 7:10:20 PM
Gravatar
Total Posts 8

Mass User Deletion

Hi guys! I've been using MojoPortal for a while and today I found that in the last few months, a few hundreds of user accounts have been created by spammers. I've disabled user registration for a while and cleaned the trash they've put into my blog's oldest comments, but I still got all their accounts to defenestrate.

I know I can do it by going into profile management, but it's tedious to delete them one by one. Is there a faster method?

I've been thinking about coding a page to get the user list from the membership provider, then have it obliterate every account, but I'm afraid with my limited knowledge I could leave some inconsistent data in the database. So if there's any way to do it via Mojo itself, I'd be quite happy to hear about it.

Thanks in advance :)

3/27/2011 8:02:56 AM
Gravatar
Total Posts 18439

Re: Mass User Deletion

Well, it could be done from the database, but the problem is how to do it without deleting all of the users, especially your own admin user. The safest way is to do it from the UI.

If there is only one user that you want to keep and you want to delete the rest of them, you could find out the userid of the one you want to keep and then delete all others with sql like this:

DELETE FROM mp_UserProperties
WHERE UserGuid IN (SELECT UserGuid FROM mp_Users WHERE SiteID = @SiteID AND UserID <> @MyUserID)

DELETE FROM mp_UserRoles
WHERE UserID IN (SELECT UserID FROM mp_Users WHERE SiteID = @SiteID)
AND UserID <> @MyUserID

DELETE FROM mp_UserLocation
WHERE UserGuid IN (SELECT UserGuid FROM mp_Users WHERE SiteID = @SiteID)
AND UserID <> @MyUserID

DELETE FROM mp_UserPages WHERE UserGuid IN (SELECT UserGuid FROM mp_Users WHERE SiteID = @SiteID AND UserID <> @MyUserID)


DELETE FROM mp_Users WHERE SiteID = @SiteID
AND UserID <> @MyUserID

Best to backup your db before attempting anything like that.

Hope it helps,

Joe

3/27/2011 8:08:14 PM
Gravatar
Total Posts 8

Re: Mass User Deletion

Thanks :) I'm going to try that!

You must sign in to post in the forums. This thread is closed to new posts.