Changing the username character limit from four to less characters

You can filter 'wpmu_validate_user_signup' and check if the error code matches the 4 character warning. Then just unset the error code.

Sample plugin:

<?php # -*- coding: utf-8 -*-
/* Plugin Name: Allow short user names for multi site. */

add_filter( 'wpmu_validate_user_signup', 'wpse_59760_short_user_names' );

/**
 * Allow very short user names.
 *
 * @wp-hook wpmu_validate_user_signup
 * @param   array $result
 * @return  array
 */
function wpse_59760_short_user_names( $result )
{
    $error_name = $result[ 'errors' ]->get_error_message( 'user_name' );
    if ( empty ( $error_name )
        or $error_name !== __( 'Username must be at least 4 characters.' )
    )
    {
        return $result;
    }

    unset ( $result[ 'errors' ]->errors[ 'user_name' ] );
    return $result;
}

Leave a Comment