The title is being converted to lowercase by filter sanitize_title
// in wp-includes/default-filters.php
add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 );
// it means => calling sanitize_title_with_dashes() in wp-includes/formatting.php
Here is explanation to what can do, recommended and not recommended method
Not Recommended
You may remove this filter but not recommmended
Because this filter is for converting title with dashes, you may go to see the source code for reference.
// in theme's php
remove_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10 );
Recommended
add filter ‘sanitize_title’ with custom checking without affecting the original features
// load later than the original filters
add_filter( 'sanitize_title', 'ws365107_custom_sanitize_title', 15, 3 );
function ws365107_custom_sanitize_title( $title, $raw_title, $context ) {
// may make use of the $_POST object data to check if it adding
// for original design $context="save" could distinguish, however, theme developers usually don't place this $context argument, so it render the argument useless
if( $context === 'save' ) {
}
// check by action if action = createuser from user-new.php, avoid affecting other situation
// please adjust if use in other situations
if( isset( $_REQUEST ) && isset($_REQUEST['action']) ) {
// custom logic in checking user name using $raw_title
$title = $raw_title;
return $title;
}
// return original title for other situations
return $title;
}
Extended reading: