Creating usernames of less than 4 characters

I wanted to create an account for my wife, her name is just three letters and so I dug around the interwebs and found this little gem Thanks very much to Lew Ayotte of

Supports Multi-sites perfectly. Simply copy the code (below) and place it in a file name of your choosing in the wp-content/mu-plugins directory. Don’t forget to enclose the function (the whole code selection below) in php tags (<?php … ?>)

function remove_username_char_limit($result) {
  if ( is_wp_error( $result[ 'errors' ] ) && !empty( $result[ 'errors' ]->errors ) ) {

    // Get all the error messages from $result
    $messages = $result['errors']->get_error_messages();
    $i = 0;
    foreach ( $messages as $message ) {

      // Check if any message is the char limit message
      if ( 0 == strcasecmp("Username must be at least 4 characters", $message)) {
        // Unset whole 'user_name' error array if only 1 message exists
        // and that message is the char limit error
        if ( 1 == count($messages) ) {
          unset( $result['errors']->errors['user_name'] );
        } else {
          // Otherwise just unset the char limit message
          unset( $result['errors']->errors['user_name'][$i] );


  return $result;
add_action('wpmu_validate_user_signup', 'remove_username_char_limit');

Please note, this is not my code, I have provided a link to the original source above. I have posted the code here in the event it is no longer available on the original site.

This entry was posted in plugins. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *