Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Restrict usernames to alphanumeric and underscore Details »»
Restrict usernames to alphanumeric and underscore
Version: 1.00, by Reynaldovb Reynaldovb is offline
Developer Last Online: Aug 2014 Show Printable Version Email this Page

Version: 3.0.3 Rating:
Released: 12-30-2004 Last Update: Never Installs: 28
 
No support by the author.

In response to
http://www.vbulletin.com/forum/showt...614#post772614

User memobug wanted (and myself too) to have a way to restrict usernames to alphanumeric chars and underscore. To me it has been a headache with a lot of users because their password didn't work, just to find after investigation that their usernames had an space and they were writing it without it. I hope this helps others as it has helped me.

Here are the instructions to do it.

1) Go to your Admin Control Panel, Phrases Manager and create a new phrase named "username_invalidchars" in the "Front-end error messages" section.

For the text use something like "Username has invalid characters. Only characters allowed are letters, numbers and underscore."



2.- Open /forums/register.php

Somewhere around line 187 you will find the following
PHP Code:
$errors = array(); 
Add the following just below that
PHP Code:
//--------------------------------------------------
    // check username does not contain UNWANTED characters
    
if (preg_match('/[^a-zA-Z0-9\_]+/'$_POST['username']))
    {
        
//eval(print_standard_error('error_username_semicolon'));
        
eval('$errors[11] = "' fetch_phrase('username_invalidchars'PHRASETYPEID_ERROR) . '";');
    }
//------------------------------------------------- 

That's it, enjoy it.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 12-31-2004, 10:51 AM
memobug memobug is offline
 
Join Date: Jun 2002
Posts: 418
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Many thanks for this. I will be checking it out over the next week or so. It will come in very handy with some new features we hope to add to our website. One for example puts the username in a path to create a custom folder, so cleaning up the usernames like this is ideal.

Regards,

Matt
Reply With Quote
  #3  
Old 12-31-2004, 12:19 PM
Reynaldovb Reynaldovb is offline
 
Join Date: Dec 2004
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Memo, I must warn you that this not correct current usernames, just the new ones. If you would like something like that, you would have to run a query directly against the DB searching and Replacing forbidden characters and then rebuilding user count and titles.
Reply With Quote
  #4  
Old 12-31-2004, 02:36 PM
pagekeeper pagekeeper is offline
 
Join Date: Sep 2003
Location: London, UK
Posts: 82
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

just curious what symbols does it block ?

i was told to use the illegal username thing, but at least this will do it properly...

i dont want to block the underscore ..... ? but i do want to block all of the following:

! " £ $ % ^ & * ( ) + - = : ~ # / \ ` ¬ | ? . , > <
Reply With Quote
  #5  
Old 01-01-2005, 09:24 AM
memobug memobug is offline
 
Join Date: Jun 2002
Posts: 418
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Reynaldovb
Memo, I must warn you that this not correct current usernames, just the new ones. If you would like something like that, you would have to run a query directly against the DB searching and Replacing forbidden characters and then rebuilding user count and titles.
Thanks, yes I'll have to find a way put all those existing folks with noncompliant usernames into their own group and get some kind of email notification out to them that their usernames were revised.

Concerning the instructions, installation went fine. You might want to clarify that the new phrase goes in "Front-End Error Messages" not Front-End User Messages" (which doesn't exist).

Thanks again,

Matt
Reply With Quote
  #6  
Old 01-01-2005, 09:26 AM
memobug memobug is offline
 
Join Date: Jun 2002
Posts: 418
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by pagekeeper
just curious what symbols does it block ?

i was told to use the illegal username thing, but at least this will do it properly...

i dont want to block the underscore ..... ? but i do want to block all of the following:

! " ? $ % ^ & * ( ) + - = : ~ # / \ ` ? | ? . , > <
As it's written, it accepts alphanumerics (A-Z a-z 0-9) and the underscore character _
No other symbols or spaces.

Regards,

Matt
Reply With Quote
  #7  
Old 01-06-2005, 04:33 AM
rlamego rlamego is offline
 
Join Date: Nov 2004
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Reynaldo!
Reply With Quote
  #8  
Old 01-06-2005, 07:00 AM
memobug memobug is offline
 
Join Date: Jun 2002
Posts: 418
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

80 new members registered in the past five days. Not a one with a wacko username.
The days of

.:VirtualInsanity:.
/<not
" J-i-m "

Are finally over. Thank you!

Regards,

Matt
Reply With Quote
  #9  
Old 01-10-2005, 12:17 PM
Odysseus's Avatar
Odysseus Odysseus is offline
 
Join Date: Oct 2002
Location: Regensburg, Germany
Posts: 88
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will this hack allow usernames with a blank space, such as "John Doe", or will this allow only "John_Doe"?
Reply With Quote
  #10  
Old 01-15-2005, 10:28 PM
Reynaldovb Reynaldovb is offline
 
Join Date: Dec 2004
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Odysseus
Will this hack allow usernames with a blank space, such as "John Doe", or will this allow only "John_Doe"?
It will only allow "John_Doe" not "John Doe" or "John-Doe"
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:59 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04848 seconds
  • Memory Usage 2,299KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete