本文最后更新于2015年5月23日,因长期没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
将以下代码添加到当前使用主题的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);
添加完代码保存后就可以使用中文注册用户名了。
wordpress4.4后不行了,怎么改呢?