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

2 Answers

+2 votes
edited by
Best answer

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

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


$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!"; }

@teddydoors And what's the code/ how to modify?
Make sure you have PHP knowledge. Try adding this

if (strlen(trim($handle)) == strlen($handle)) {
return 'No space, boy';
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,
Hey, harshal852, try this, it works after re-investigation. You put in inside public function filter_handle(&$handle, $olduser):

function filter_handle(&$handle, $olduser) {

        $subhandle = str_replace(' ', '', $handle);
        if (strlen($subhandle) !== strlen($handle)) {
return 'Spaces are not allowed.' ;
//all other filter conditions


Double check if I'm wrong.
0 votes

This answer is for fazleysabbir because I cannot insert image in a comment.

At least, I did test the added code in the qa-filter-basic.php file. Next time, test a code before commenting please.

fazleysabbir is a prick