My drupal site has a textarea field in the new user application that asks for the new user to explain what their interest is in wanting to join the site. Some sort of machine bot is sending a dozen or so requests for accounts daily. Characteristically, this machine bot is putting two random characters into this "interest" field. Therefore, I know that any account with only 2 characters in this particular field is this computer bot since no answer to this question on the application could be acceptable with only two characters.

I would like to know if there is a way that drupal can delete such accounts with only two characters in this particular field automatically by using a set criteria (e.g. a field containing only two characters). How could I go about this? It would be ideal to have Drupal NOT send an email message at all that a new user has signed up when this occurs, but if that is not possible, then can I do something to automatically delete such an application when the length of the field is only two characters? I am looking for a Drupal method of doing this rather than a cron job method of doing this.

I realize that one could just use a field validation to start with but that won't answer the question: Can Drupal actually use some sort of specific field rule (e.g. a certain field must have more than x number of characters) to delete accounts automatically so they wouldn't have to be deleted manually and constantly by the administrator.


You may not be able to stop the email being sent. But you can set up a rule to block the user to trigger on the event 'Before saving user account'.

You will require two conditions. First use the condiiton 'Entity has field' and check for the 'Reasons to join' field. This will make the field visible to subsequent conditions. The do a 'Data comparison' on account-unchanged:profile-main:user:field-reasons-to-join and check for your two charcter text. If the conditions are met use an action to 'Block a user' using account-unchanged:profile-main:user.

EDIT: Since your users are blocked pending admin approval, perhaps you should be looking at the Field validation module. With it you can specify a minimum length for the field (making sure you let your users know in the guidelines that the minimum length is required). You could also set up a field hidden with your css which you would require to be empty. Bots would likely fill it in with something.

You should also have a look at the Spambot module which uses the api at stopforumspam.com to catch known spammers. While it is not perfect (nothing is) it will certainly cut down on the number of bots that get through.

  • Thank you. The accounts are not allowed to be active, rather, all are blocked until administrator approval. However, I am interested in somehow deleting them or not allowing them to exist unless the certain profile field has at least 10 characters, for example. This will eliminate most of these spam accounts before I get to the list. Is this possible?
    – Q Beat
    Apr 8 '13 at 23:56
  • @Q Beat - So it is not as simple as a mass delete of blocked users. I have added a couple of suggestions to my answer.
    – Triskelion
    Apr 9 '13 at 0:16
  • I installed the Field Validation module as suggested. We will see if that works. What I had in mind is to simply delete all accounts if the field in question had only two characters. The problem with your suggestion is that it tells the spammers that they need to adjust their way of doing things, thus it will only be a small amount of time before the spam accounts reappear with longer gibberish in that field. I am thinking of a cron job that tests blocked accounts for valid length and deletes those that do not meet criteria. I just don't know the mysql string to test for length of field.
    – Q Beat
    May 25 '13 at 22:28
  • I have refrased the question to seek an answer about deleting accounts automaticaly based on a certain criteria rather than to block accounts from being created in the first place. Thanks for your help, @Triskelion
    – Q Beat
    May 30 '13 at 3:36
  • You should not change this question. Ask a new one instead.
    – Triskelion
    May 30 '13 at 3:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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