wordpress博客注册时支持中文名称

我自己测试过,不支持中文注册,我是使用露兜博客:(新版)让wordpress支持中文用户名的简便方法解决的。建议配合使用插件:Ludou custom register

在functions.php文件中添加下面代码:

function ludou_sanitize_user ($username, $raw_username, $strict) {
$username = wp_strip_all_tags( $raw_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

// 网上很多教程都是直接将$strict赋值false,
// 这样会绕过字符串检查,留下隐患
if ($strict) {
$username = preg_replace ('|[^a-z\p{Han}0-9 _.\-@]|iu', '', $username);
}

$username = trim( $username );
// Consolidate contiguous whitespace
$username = preg_replace( '|\s+|', ' ', $username );

return $username;
}

add_filter ('sanitize_user', 'ludou_sanitize_user', 10, 3);

历史上的今天:

  • 2022: 原来不止我一个人感觉累 (0 Comments)
  • 2021: 快手极速版,收款11.3元 (0 Comments)
  • 2021: 菜贵的离谱,我怕我要吃不起饭了 (0 Comments)
  • 2021: EDG获得S11冠军,EDG牛逼 (0 Comments)
  • 2018: 《橙红年代》小说看完了,开始看《铁器时代》 (5 Comments)
  • © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0 分享
    评论 共1条
    头像
    欢迎您留下宝贵的见解!
    提交
    头像

    昵称

    取消
    昵称表情代码图片
      • 头像天津网站建设0