相关文章推荐
风流的板栗  ·  香港閱讀城·  1 年前    · 
考研的台灯  ·  OH 3.3.0 Frontail not ...·  1 年前    · 
知识渊博的斑马  ·  Excel ...·  2 年前    · 
自信的胡萝卜  ·  Nosql-neo4j-Cypher 语句 ...·  2 年前    · 

wordpress在默认情况下不支持中文用户名,就是在后台添加用户的时候,如果用户名包含中文,则显示” 错误:此用户名包含无效字符,请输入有效的用户名 。”如何解决这个问题呢?

不用插件的话就需要修改一个文件,找到w-includes/formatting.php

查找function sanitize_user( $username, $strict = false ) { ?这一行代码,然后在他下面加入

$strict = false;

function sanitize_user ( $ username , $ strict = false ) {
$ strict = false ; //添加的代码
$ raw_username = $ username ;
$ username = wp_strip_all_tags ( $ username ) ;
$ username = remove_accents ( $ username ) ;
// Kill octets
$ username = preg_replace ( '|%([a-fA-F0-9][a-fA-F0-9])|' , '' , $ username ) ;
$ username = preg_replace ( '/&.+?;/' , '' , $ username ) ; // Kill entities