wordpress在默認情況下不支持中文用戶名,就是在后臺添加用戶的時候,如果用戶名包含中文,則顯示”錯誤:此用戶(hu)名包含無(wu)效字(zi)符,請輸入有效的(de)用戶(hu)名。”如(ru)何解決這個問題呢?
不用插件的話就(jiu)需要(yao)修(xiu)改一個文(wen)件,找到(dao)w-includes/formatting.php
查找function sanitize_user( $username, $strict = false ) { ?這一行代碼,然后(hou)在他下面加入
$strict = false;
最后變為
functionsanitize_user($username,$strict=false){
$strict=false;//添(tian)加(jia)的代碼
$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


發表評論 取消回復