Blocking inappropriate usernames

Submitted by Barrett on Thu, 10/23/2008 - 08:26
Blocking inappropriate usernames

A question came up in one of the forum posts on about a module to prevent inappropriate usernames.  A couple options were discussed, including using access rules and the abuse module.  Mostly as a learning exercise, I decided to try my hand at writing a module to handle the issue. The code I came up works with Drupal 5.x and uses the validate operation of hook_user to check for inappropriate names and return an error.

The module is not without problems, of course.  Specifically, it relies on a defined blacklist of names to block and won't match permutations of those names which would be obvious to people but which are not specifically defined in the blacklist (e.g., "b4dw0rd1" would be accepted).  On the other side, though, making the code more robust in terms of name blocking runs an increasing risk of false positives being blocked.  Also, in a production quality module, the blacklist contents and the error message returned should be defined through an administrative form rather than hard coded.  As a learning exercise, though, I count the module as a complete success.

Barrett Thu, 10/23/2008 - 08:26