Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
768 views
in Q2A Core by
To avoid confusing users, I want to prohibit words such as admin, moderator, etc. in the username. How can I do that?

1 Answer

+4 votes
by

Modify function qa_handle_email_validate(...) in qa-app-users-edit.php. That function applies various rules to $handle (like maximum length), so you can add more rules in there via PHP code.

by
edited by
Thanks Gideon! Here is what I did in case anyone else wants it:

Open qa-app-users-edit.php for edit

After this line:
$errors['handle']=qa_lang_sub('main/max_length_x', QA_DB_MAX_HANDLE_LENGTH);

Add the following code:
elseif (preg_match('/admin|moderator/', $handle, $matches))
  $errors['handle']=qa_lang_sub('main/word_not_allowed_in_username', $matches[0]);


Now, you need to make an error message for it. Open qa-lang-main.php for edit.

Add something like this to the array:

'word_not_allowed_in_username' => "Sorry, the word '^' is not allowed in the username.",


That's all.
...