Allowing Non-Latin Characters In WordPress Registration

by Hamed   Last Updated March 14, 2019 21:08 PM

There exist a plugin for wordpress to enable usernames containing special characters (russian, cyrillic, arabic …). Unfornetly this plugin didn't work for me. Here is the function defined to register users in the the theme I'm using (QAEngine theme)

public function register(){
    $param = $_REQUEST['content'];
    $args  = array(
        'user_email'    => $param['email'],
        'user_pass'     => $param['password'],
        'user_login'    => $param['username'],
        'display_name'  => isset($param['display_name']) ? $param['display_name'] : $param['username']
    );
    $captcha = isset($_REQUEST['captcha']) ? $_REQUEST['captcha'] : '';
    // validate here, later
    try {

        //verify captcha
        ae_verify_captcha($captcha, __('Please enter a valid captcha!', ET_DOMAIN));

        $role = apply_filters('qa_custom_role', 'author' );
        do_action ('je_before_user_register', $args);

        // apply register & log the user in
        $auto_sign  = ae_get_option( 'user_confirm' ) ? false : true;
        $user_id    = et_register( $args , $role, $auto_sign );

        if ( is_wp_error($user_id) ){
            throw new Exception($user_id->get_error_message() , 401);
        }

        $data     = get_userdata( $user_id );
        $userdata = QA_Member::convert($data);
        // generate new nonces
        $msg = ae_get_option( 'user_confirm' ) ? __('You have registered an account successfully but are not able to join the discussions yet. Please confirm your email address first.', ET_DOMAIN) : __('You are registered and logged in successfully.', ET_DOMAIN) ;
        $response = array(
            'success'       => true,
            'code'          => 200,
            'msg'           => $msg,
            'data'          => $userdata,
            'redirect'      => apply_filters( 'qa_filter_redirect_link_after_register', home_url() )
        );

    } catch (Exception $e) {
        $response = array(
            'success' => false,
            'code'    => $e->getCode(),
            'msg'     => $e->getMessage()
        );
    }
    wp_send_json( $response );
}

Here you could find a complete php file in which this function is declared.

Any recommendation for how to allow non-latin characters in usernames?

Tags : php username


Related Questions



How to retrieve lost username/ email log- in ?

Updated February 19, 2017 15:08 PM

Remove custom number from AMP pages

Updated November 06, 2018 08:08 AM

How to assign a UserName value at creation

Updated December 24, 2018 21:08 PM

How to change a username?

Updated August 22, 2017 05:08 AM