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
  #22  
Old 02-19-2005, 03:38 PM
Tomek Tomek is offline
 
Join Date: Oct 2004
Location: Germany, Paderborn
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by clearchannel
I would like to install this hack in vB 3.06. I would also like to allow spaces in usernames. Which of the above code would be correct to use in 3.06?
PHP Code:
 if (preg_match('/[^a-zA-Z0-9\_\s]+/'$_POST['username'])) 
The \s is for spaces.
Reply With Quote
  #23  
Old 02-20-2005, 03:14 AM
Andy Andy is offline
 
Join Date: Sep 2003
Location: San Francisco
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you Reynaldovb. The hack works perfectly. I also allowed space and the period.
Reply With Quote
  #24  
Old 02-20-2005, 08:55 PM
evilTone evilTone is offline
 
Join Date: Apr 2004
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

installed
nice simple hack

mucho thanks
Reply With Quote
  #25  
Old 02-24-2005, 04:34 PM
slix slix is offline
 
Join Date: Jul 2004
Location: Devon, England
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is great but I need it to go one further..... my new users must have both letters and numbers in their user name. How do I do that?
Reply With Quote
  #26  
Old 02-27-2005, 06:56 AM
slix slix is offline
 
Join Date: Jul 2004
Location: Devon, England
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*bump*
Reply With Quote
  #27  
Old 02-28-2005, 04:26 PM
rjordan's Avatar
rjordan rjordan is offline
 
Join Date: Sep 2004
Posts: 326
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It looks to me that it will allow numbers and letters already.
Reply With Quote
  #28  
Old 02-28-2005, 08:04 PM
slix slix is offline
 
Join Date: Jul 2004
Location: Devon, England
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by rjordan
It looks to me that it will allow numbers and letters already.
Yea I know it will, but I need it to force users to have both numbers and letters in their user name. For example "fred_20".

Any one?
Reply With Quote
  #29  
Old 03-06-2005, 12:35 PM
rjordan's Avatar
rjordan rjordan is offline
 
Join Date: Sep 2004
Posts: 326
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have been looking, but have not found anything that I can get working. This WOULD be nice to have...
Reply With Quote
  #30  
Old 11-28-2005, 05:30 PM
Alphawolf83's Avatar
Alphawolf83 Alphawolf83 is offline
 
Join Date: Mar 2005
Location: Germany
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Simple little nice hack *clicks install*
Reply With Quote
  #31  
Old 02-01-2006, 03:56 AM
Tk1 Tk1 is offline
 
Join Date: Jan 2006
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi all,

Will this work on vB 3.5.3 ?

If not, can anyone... perhaps port or upgrade it ?
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 02:55 PM.


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.07215 seconds
  • Memory Usage 2,308KB
  • Queries Executed 25 (?)
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
  • (3)bbcode_php
  • (2)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
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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