$errors =
new WP_Error();
$orig_username =
$user_name;
$user_name =
preg_replace( '/\s+/', '',
sanitize_user( $user_name, true
) );
if ( $user_name !=
$orig_username ||
preg_match( '/[^a-z0-9]/',
$user_name ) ) { $errors->
add( 'user_name',
__( 'Usernames can only contain lowercase letters (a-z) and numbers.'
) );
$user_name =
$orig_username;
} $user_email =
sanitize_email( $user_email );
if ( empty( $user_name ) ) { $errors->
add( 'user_name',
__( 'Please enter a username.'
) );
} $illegal_names =
get_site_option( 'illegal_names'
);
if ( !
is_array( $illegal_names ) ) { $illegal_names = array
( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator'
);
add_site_option( 'illegal_names',
$illegal_names );
} if ( in_array( $user_name,
$illegal_names, true
) ) {