4

I need to add username in hebrew,

I have added this,

add_filter( 'sanitize_user', 'sanitize_user_with_hebrew', 10, 3 );

function sanitize_user_with_hebrew( $username, $raw_username, $strict ) {

$username = $raw_username;
$username = wp_strip_all_tags( $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

// If strict, reduce to ASCII for max portability.
if ( $strict ) {
    $username = preg_replace( '|[^a-z0-9א-ת _.\-@]|i', '', $username );
}

$username = trim( $username );
// Consolidate contiguous whitespace
$username = preg_replace( '|\s+|', ' ', $username );

/**
 * Filter a sanitized username string.
 *
 * @since 2.0.1
 *
 * @param string $username     Sanitized username.
 * @param string $raw_username The username prior to sanitization.
 * @param bool   $strict       Whether to limit the sanitization to specific characters. Default false.
 */

return $username;
}

And this allows to add username in hebrew username, but I can't see the name in users.php in backend. I see blank.

My site is in Hebrew.

Thanks

  • 1
    How did you go with this @hkchakladar? Did the solution posted below help you? – Tim Malone Jun 29 '16 at 4:44
0

check this plugin hebrew username

u need to use regex - [\p{Hebrew}a-zA-Z]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.