Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
620 views
in Q2A Core by
Hi

users can take "ü,ö,ç, ? !" etc in ther nicknames but it really disgusting can we block that ?

thank you
Q2A version: Latest

1 Answer

+2 votes
by
selected by
 
Best answer

Yes. You can write a plugin to do so which includes a filter module. You'll want to focus on the filter_handle() method.

This method will almost make the whole plugin for you: https://github.com/q2a/question2answer/blob/4fce0eb2390f56b645dad375d1d81e9f91a97e69/qa-include/plugins/qa-filter-basic.php#L41 . Just copy/paste, remove the unneeded stuff and change the regular expression to whatever you want, which I get the impression should be something close to '/[^0-9a-zA-Z]/', based on your comments.

by
edited by
thank you for comment i try without plugin and i do somthing but it not work


    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);

        }

    }

please can you more expain :D
by
If you don't want to use a plugin you could just replace:

\\@\\+\\/

with:

^0-9a-zA-Z

You could also replace '@ + /' with '' and change the corresponding language file for: users/handle_has_bad . That way the error could be 'Username can only contain characters from A to Z and numbers'.
by
edited by
I can't manage this i do but it still don't effect to register screen
i look that later thx

I do that and it works thanks to you !
...