In module version 6.x-1.2 one can change the validation requirements of the user registration/edit form. But, under the username field there is a text stating the default drupal requirements of a username "Spaces are allowed...". This is not valid anymore if this module is used. So, this module should change the text to some custom string.
Attached patch will add this feature to 6.x-1.2 version of Custom Username Validation module. Since CVS version seems deprecated patch was made from 6.x-1.2 instead.
This patch will add a field on the module configuration page. If one specifies a description text there, this text will be used in user registration/edit form instead of drupal default. If blank, drupal default is used.
Tested and works with drupal 6.17. Needs review and commit to CVS.
Even if CVS is pain, it is nice to have an updated version in CVS repository :).
//Freidrichen
| Comment | File | Size | Author |
|---|---|---|---|
| custom_username_validation.module.patch | 1.25 KB | freidrichen |
Comments
Comment #1
Schneck commentedThanks for the patch; basically it's good, but there's a point that prevents it from working here:
in the function
custom_username_validation_form_alter() {}you added:$form['account']['name']['#description'] = $hint;But there is no 'account' key in the form. In a default installation, it must be:
$form['name']['#description'] = $hint;Could it be that you have any other module installed rewriting the array?
Comment #2
Schneck commentedI figured it out. thanks again. I committed an updated 1.3-version, containing another some other improvements, including a pattern-testing-function. Could you please report back shortly if everything's running fine?
Comment #3
freidrichen commentedIt seems that your 1.3 version is actually not updated. The only thing that has changed in the .module file is the date in the header.
Please try updating again and I will gladly try it out.
//Freidrichen
Comment #4
Schneck commentedah, i love cvs ;) ok, i tagged and committed again, to 1.4. as soon as the drupal package scripts have been run, it will be available for download. since the file size increased, i hope it worked this time.
Comment #5
freidrichen commentedNow it seems the new code is in the release, and it works! Yay!
I have a couple of things to point out though. In order of discovery, not of importance so please check them all.
1. In the file .module the version still says 1.3 at the top. Should have been 1.4, or 1.5 for next. But maybe this is done by the CVS, so it might be evil.
2. It seems you have added a permission. This is a kinda big thing and should be mentioned explicitly in the module config page. Also, if I am admin (user uid 1) then I have all permissions by default and therefore I can add any username regardless of restrictions in this module. This is fine, but it should be stated somewhere, preferably on the module configuration page (Site configuration->custom username validation). If possible I would dream of a checkbox "enable restrictions also for admin" or something, because in my case it's bad even if the site admin creates accounts with malformed usernames.
3. If I just replace the old module files with the new ones I get a funny error every time I try to use the "Test pattern" function. I get a popup saying: "An HTTP error 404 occurred. /?q=custom_username_validation/test_validation. " I suspected something was fishy with the update, so I ran update.php. After that the error disappears. So maybe the module requires the update.php to be ran after update. I dunno really, but I don't get that error anymore. Maybe it was just in need of some page refresh or something.
4. I accidentally tested your function with the regexp .* instead of /.*/. I got no error message from the preg_match function. I guess this is because you have an @ character in front of the preg_match function in the code, and I guess this removes errors from the preg match. Why is this? I think the pure "preg_match" without the @ char would be better! Then you will get a nice error message instead of silent failure if you type in a malformatted regexp.
5. There is a stray "global $user" from some earlier debugging in the validation function.
Over all, thanks for your fast response and a good module.
//Freidrichen feat. MagicalBengt
Comment #6
Schneck commentedHi there,
first sorry for the delay, I was pretty busy that last weeks. Today, I commited some patches according to open issues and some of your points:
1. Maybe it's the packaging scripts, I did not change the info file in the last release
2. I added a note in the admin section, good point. For the admin, it's still possible to override the pattern, I will consider implementing this functionality in the next release
3. Strange - I tested it and did not have the problem. I will add a note to the project page.
4. Thanks for this, I implemented it.
5. removed
So thanks for all of your input, I released 1.5 today. Could you please check if there is everything going well?
Stefan