How do I add a filter to the username field to stop new users from registering using unwanted words such as administrator
or general profanity?
Ideally, if I could add a large list of words that are blocked with the option to add asterisk (*) as a wildcard like genitals*
.
There are two very different hooks you can use, depending on the installation:
wpmu_validate_user_signup
for multi-site andregistration_errors
for single-site.The following untested code shows how to use them. You can tweak the array in
user_name_is_forbidden()
to your needs. Use regular expressions for the matches.