Skip to content

Instantly share code, notes, and snippets.

@teknikqa
Created September 29, 2020 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teknikqa/e65c9fd0aea6f0342f05ace2c6673961 to your computer and use it in GitHub Desktop.
Save teknikqa/e65c9fd0aea6f0342f05ace2c6673961 to your computer and use it in GitHub Desktop.
Allow very short user names in WordPress.
<?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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment