I am trying to fix a site that has had more than 10,000 spam user registrations. However, some legitimate user registrations have also been made, so I cannot simply delete all the accounts.

Manually sorting through all of this would take a very long time. However, it appears to be the case that no spam users made any comments or created any nodes. So, I thought I might be able to create a view that shows all the users that have not created content or made any comments, and then use VBO to delete all such users.

But, although I can make a view that shows users who have created content, I haven't been able to figure out a way that shows users who have not created any content/comments. How might I go about this?

1 Answer 1


Before some days I was also work on some thing like this. In my registration page there is a field named looking-for. I was created a view to show all the members as per there looking-for field. It mean that if user selected male in looking for then only male is shown. I have added below code in the view. You can change condition as per your condition & add relationship & filter criteria.

global $user;
  $profiles = profile2_load_by_user($user);
    foreach ($profiles as $profile) {
        if ($items = field_get_items('profile2', $profile, 'field_sex')) {
 if($i_am=='sdmale' || $i_am=='sbmale'){



if($i_am=='smfemale' || $i_am=='sbfemale'){



   return $looking;
  • Thanks for this code, but I don't want to check a user profile value; I want to check for users who have not made any nodes on the site. Oct 13, 2014 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.