不用WordPress插件即可轻松实现,将下面代码插入到当前主题functions.php中即可!

//WordPress支持中文名注册,来自酱茄 jiangqie.com
function git_sanitize_user ($username, $raw_username, $strict) {
$username = wp_strip_all_tags( $raw_username );
$username = remove_accents( $username );
$username = preg_replace( ‘|%([a-fA-F0-9][a-fA-F0-9])|’, ”, $username );
$username = preg_replace( ‘/&.+?;/’, ”, $username ); // Kill entities
if ($strict) {
$username = preg_replace (‘|[^a-z\p{Han}0-9 _.\-@]|iu’, ”, $username);
}
$username = trim( $username );
$username = preg_replace( ‘|\s+|’, ‘ ‘, $username );
return $username;
}
add_filter (‘sanitize_user’, ‘git_sanitize_user’, 10, 3);

版权声明:酱茄所提供的文章、图片等内容均为用户发布或互联网整理而来,仅供学习参考,如有侵犯您的版权,请联系:help@jiangqie.com,我们将在3日内删除。

猜你喜欢
发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论信息