解决错误:此用户名包含无效字符,请输入有效的用户名。wordpress不能注册中文用户名的问题…

admin 2019年5月19日03:02:57WordPress技巧评论2,241 次浏览阅读模式

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

相关文章
weinxin
我的微信
微信扫一扫
admin
  • 本文由 发表于 2019年5月19日03:02:57
  • 转载请务必保留本文链接:https://anyun.org/a/webtips/wordpressjiqiao/2019/0519/9558.html

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: