//WordPress支持中文用户名
function fanly_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 );
    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', 'fanly_sanitize_user', 10, 3);

添加到functions.php。


最后修改:2019 年 06 月 06 日
如果觉得我的文章对你有用,请随意赞赏