If you create a network of sites using the WordPress Multisite feature, you’ll notice that you aren’t allowed to add users with hyphens (or dashes) in their username.

Unfortunately it seems to be quite difficult to fix this problem, however I came across a post by toscho on WordPress Stackexchange that helped me write a solution.

Drop this code in your functions.php file (remember to remove the <?php at the top) and you’ll be allowed to register users with hyphens in their username.

If you take a look at the original wpmu_validate_user_signup function in wp-includes/ms-functions.php, you’ll notice that I’ve slightly modified the regex test to allow for a hyphen. Of course, you can also add your own regex if you want to allow other characters as well.

If this post has helped you out, feel free to consider throwing a small donation my way.