Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
898 views
in Q2A Core by
by
Can somebody tell me ? Only a~z _ 0~9 can be used

1 Answer

+3 votes
by

This question has some detail in the comments. In your case you'd probably want to use preg_match like this:

    preg_match('/^[a-zA-Z0-9_]+$/', $handle, $matches)

 

by
Where do I put this code?
qa-app-users-edit.php or qa-filter-basic.php or ... ?
sorry i'm an amateur.
by
Follow the instructions in the comment on the linked question. It starts "Open qa-app-users-edit.php for edit".

Then instead of where it says:
  preg_match('/admin|moderator/', $handle, $matches)
You would put:
  preg_match('/^[a-zA-Z0-9_]+$/', $handle, $matches)
by
Hi @Scott, could you please help me to implement this on the version 1.7.4. I tried to make it work by following steps. However after I made changes to the code, it doesn't allow (a~z _ 0~9) any of this characters to be used, but every other characters work except the following 3 characters @ / +.
by
@Ankhamax the best way in the latest Q2A is to make a filter module: http://docs.question2answer.org/plugins/modules-filter/
You'll want to use the filter_handle method.

What characters exactly do you want to restrict in the username? If you want to limit to only alphanumeric characters then the above regex in my answer will work.
...