也想出现在这里?联系我们

wordpress注册账号支持中文名注册

  • 文章介绍
  • 升级版本
  • 评价&建议

直接贴代码,实现wordpress注册账号支持中文名注册!将下面代码插入到functions.php即可!

  1. //支持中文名注册,来自肚兜
  2. function git_sanitize_user ($username$raw_username$strict) {
  3.   $username = wp_strip_all_tags( $raw_username );
  4.   $username = remove_accents( $username );
  5.   $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', ''$username );
  6.   $username = preg_replace( '/&.+?;/', ''$username ); // Kill entities
  7.   if ($strict) {
  8.     $username = preg_replace ('|[^a-z\p{Han}0-9 _.\-@]|iu', ''$username);
  9.   }
  10.   $username = trim( $username );
  11.   $username = preg_replace( '|\s+|', ' ', $username );
  12.   return $username;
  13. }
  14. add_filter ('sanitize_user', 'git_sanitize_user', 10, 3);
  15. // 评论添加@,来自:http://www.ludou.org/wordpress-comment-reply-add-at.html
  16. function git_comment_add_at( $comment_text$comment = '') {
  17.   if$comment->comment_parent > 0) {
  18.     $comment_text = '@<a href="#comment-' . $comment->comment_parent . '">'.get_comment_author( $comment->comment_parent ) . '</a> ' . $comment_text;
  19.   }
  20.   return $comment_text;
  21. }
  22. add_filter( 'comment_text' , 'git_comment_add_at', 20, 2);
有用2
  • 2017.08.28初次和大家见面了!

等待您对该主题的建议

发表评论

还能输入240个字

Hi, 欢迎加入Wordpress技术交流群,带你装逼带你飞!

我要入群
也想出现在这里?联系我们
wordpress加速

我来推荐一个更牛逼的给你看看?

  • 猛戳我吧