Created
September 29, 2020 09:54
-
-
Save teknikqa/e65c9fd0aea6f0342f05ace2c6673961 to your computer and use it in GitHub Desktop.
Allow very short user names in WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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