Owning a blog is really tough to maintain especially if you are gaining popularity already. There will come a time where a few spam users will come to your site and just post spam in your every post. This is one of the annoyances of having a blog but there are ways to prevent it like using plugins like re-captcha and even taking advantage of Akismet. However, if you are trying to fix the problem, deleting a lot of spam users can take forever.
So, here is a simple code to get rid of spam users in your WordPress site: