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

2 Answers

+1 vote
by
edited by
 
Best answer

Adding this snippet of code at qa-include/pages/register.php:90 is enough.

if (strpos(trim($inhandle),' ')) {

$qa_content=qa_content_prepare();

$qa_content['error'] ="Spaces are not allowed in username!";

return $qa_content;

}

Edit: To prevent username from being changed after register, you may use this code at qa-include/pages/account.php after 92 line.

if (strpos(trim($inhandle),' ')) { $errors['handle']="Spaces are not allowed in username!"; }

by
+1
Why this answer is flagged? Please unflag!
by
If you modify in  qa-include/pages/register.php, you can block those usernames when they register. But after that, they can edit their profiles!

This is not enough!
by
In this case, changing username option should be disabled or implement this code to there.
by
Answer has been updated..Take a look!
by
Or you can simply just  modify the filter_handle function found in /qa-include/plugins/qa-filter-basic.php . This will work in every case.
by
@teddydoors And what's the code/ how to modify?
by
Lol...The q2a core does the same thing you did..First, understand the question and then comment..He meant that there would be no space in the handle..And your code makes no sense,
+4 votes
by

Add this code at qa-include/plugins/qa-filter-basic.php:51

if (preg_match('/\\s/', $handle)) {

    return qa_lang_sub('users/handle_has_bad', 'space');

}

...