Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
80 views
in Q2A Core by
closed by

Hello,

I would like to blacklist some special characters to be used in username.

They are: - # ; ' * ! | ( )"$ , `,<>=&

Actually I would like to include . (dot), / (slash) + (plus) and @ (at sign) but those are already purged.

I don't want to limit the usernames to alphanumeric, just disallow those mentioned special characters.

closed with the note: Who cares?

1 Answer

+1 vote
by

Manipulate this filter_handle function found in /qa-include/plugins/qa-filter-basic.php

    public function filter_handle(&$handle, $olduser)
    {
        if (!strlen($handle)) {
            return qa_lang('users/handle_empty');
        }
        if (in_array($handle, array('.', '..'))) {
            return qa_lang_sub('users/handle_has_bad', '. ..');
        }
        if (preg_match('/[\\@\\+\\/\\#\\,\\`\\"\\*\\!\\|\\(\\)\\$\\;\\^\\=\\<\\>]/', $handle)) {
            return qa_lang_sub('users/handle_has_bad', '@ + /');
        }
        if (qa_strlen($handle) > QA_DB_MAX_HANDLE_LENGTH) {
            return qa_lang_sub('main/max_length_x', QA_DB_MAX_HANDLE_LENGTH);
        }
        // check for banned usernames (e.g. "anonymous")
        $wordspreg = qa_block_words_to_preg(qa_opt('block_bad_usernames'));
        $blocked = qa_block_words_match_all($handle, $wordspreg);
        if (!empty($blocked)) {
            return qa_lang('users/handle_blocked');
        }
    }
 

...