:如何让wordpress支持中文用户名

:

  今天介绍新的方法,借鉴了wp-includes/formatting.php中sanitize_user函数的写法,同样是将以下php代码复制到当前主题目录下的functions.php中,即可让WordPress支持使用中文用户名注册和登录:

  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) {


上一篇: WordPress获取指定分类及其子分类文章数

下一篇: WordPress 获取当前文章ID的方法

最新文章

热门文章

快读网 轻松阅读 享受快乐生活

网站邮箱:wodd7@hotmail.com

Top