How can I add a custom username restriction settings?

Get help with installation and running phpBB 3.1.x here. Please do not post bug reports, feature requests, or extension related questions here.
Ideas Centre
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: phpBB 3.1.x is at its End of Life stage and support will NOT be provided after July 1st, 2018.
Locked
samuel404
Registered User
Posts: 19
Joined: Wed May 11, 2016 5:44 am

How can I add a custom username restriction settings?

Post by samuel404 »

I've add a line of code at includes/functions_user.php

Code: Select all

case 'USERNAME_CUSTOM':
			$pcre = true;
			$regex = '[\w<>._!-]';
		break;
But I couldn't select this setting in admin panel, is there anything else I should do?
User avatar
John connor
Registered User
Posts: 2557
Joined: Fri Nov 14, 2014 5:14 pm
Location: U S Of A
Name: Aaron
Contact:

Re: How can I add a custom username restriction settings?

Post by John connor »

So you're trying to prevent a certain username from being used? All you have to do is go into the ACP under Users & Groups bottom left, Disallow usernames.
Having spam problems? Install this extension and/or this script.
How to help protect your site from hackers.
0FL ?FE<JKCP K?@EB PFL ;<:F;<;‌​​​​‌‌⁠‌‌​‌‌‌‌⁠‌‌​‌‌‌​⁠‌‌​​‌‌‌⁠‌‌‌​​‌​⁠‌‌​​​​‌⁠‌‌‌​‌​​⁠‌‌‌​‌​‌⁠‌‌​‌‌​​⁠‌‌​​​​‌⁠‌‌‌​‌​​⁠‌‌​‌​​‌⁠‌‌​‌‌‌‌⁠‌‌​‌‌‌​⁠‌‌‌​​‌‌⁠‌​​​​‌⁠‌​​​​​⁠‌​‌‌​​‌⁠‌‌​‌‌‌‌⁠‌‌‌​‌​‌⁠‌​​‌‌‌⁠‌‌‌​​‌​⁠‌‌​​‌​‌⁠‌​​​​​⁠‌‌‌​​‌‌⁠‌‌​‌‌​‌⁠‌‌​​​​‌⁠‌‌‌​​‌​⁠‌‌‌​‌​​⁠‌‌​​‌​‌⁠‌‌‌​​‌​⁠‌​​​​​⁠‌‌‌​‌​​⁠‌‌​‌​​​⁠‌‌​​​​‌⁠‌‌​‌‌‌​⁠‌​​​​​⁠‌​​‌​​‌⁠‌​​​​​⁠‌‌‌​‌​​⁠‌‌​‌​​​⁠‌‌​‌‌‌‌⁠‌‌‌​‌​‌⁠‌‌​​‌‌‌⁠‌‌​‌​​​⁠‌‌‌​‌​​⁠‌​‌‌‌​ K?@J D<JJ8><t +?@EB 8>8@Ec
samuel404
Registered User
Posts: 19
Joined: Wed May 11, 2016 5:44 am

Re: How can I add a custom username restriction settings?

Post by samuel404 »

John connor wrote:So you're trying to prevent a certain username from being used? All you have to do is go into the ACP under Users & Groups bottom left, Disallow usernames.
No, I'm trying to allow certain characters only that was written in my regex. it's whitelist, not blacklist.
Last edited by samuel404 on Mon Jun 06, 2016 9:01 am, edited 1 time in total.
samuel404
Registered User
Posts: 19
Joined: Wed May 11, 2016 5:44 am

Re: How can I add a custom username restriction settings?

Post by samuel404 »

Someone help me please, I really needed this.
User avatar
JimA
Community Team Leader
Community Team Leader
Posts: 7796
Joined: Thu Jul 31, 2008 5:54 am
Location: The Netherlands
Name: Jim Mossing Holsteyn
Contact:

Re: How can I add a custom username restriction settings?

Post by JimA »

All you're doing with your edit is telling the registration process what to look for if the setting is chosen.

You haven't added the actual option itself to the ACP yet.

Open: includes/acp/acp_board.php
Find: (around line 855)

Code: Select all

$user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII'); 
Replace with:

Code: Select all

$user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII', 'USERNAME_CUSTOM');
Open: language/en/acp/board.php
Find:

Code: Select all

'USERNAME_ASCII'            => 'ASCII (no international unicode)',
After, add:

Code: Select all

'USERNAME_CUSTOM'            => 'Own custom username settings',
Jim Mossing Holsteyn - Community Team Leader
Knowledge Base | Documentation | Board rules

If you're having any questions about the rules/customs of this website, feel free to drop me a PM.
samuel404
Registered User
Posts: 19
Joined: Wed May 11, 2016 5:44 am

Re: How can I add a custom username restriction settings?

Post by samuel404 »

JimA wrote:All you're doing with your edit is telling the registration process what to look for if the setting is chosen.

You haven't added the actual option itself to the ACP yet.

Open: includes/acp/acp_board.php
Find: (around line 855)

Code: Select all

$user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII');
Replace with:

Code: Select all

$user_char_ary = array('USERNAME_CHARS_ANY', 'USERNAME_ALPHA_ONLY', 'USERNAME_ALPHA_SPACERS', 'USERNAME_LETTER_NUM', 'USERNAME_LETTER_NUM_SPACERS', 'USERNAME_ASCII', 'USERNAME_CUSTOM'); 
Open: language/en/acp/board.php
Find:

Code: Select all

'USERNAME_ASCII'            => 'ASCII (no international unicode)', 
After, add:

Code: Select all

'USERNAME_CUSTOM'            => 'Own custom username settings', 
Thank you very much.
User avatar
3Di
Former Team Member
Posts: 15875
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: How can I add a custom username restriction settings?

Post by 3Di »

Let's see you the next phpBB update?
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
Looking for a specific feature or alternative option? We will rock you! 🚀
User avatar
Mick
Support Team Member
Support Team Member
Posts: 22647
Joined: Fri Aug 29, 2008 9:49 am
Location: Watching cricket probably.

Re: How can I add a custom username restriction settings?

Post by Mick »

3Di wrote:Let's see you the next phpBB update?
Indeed.

@OP: While you seem to have the fix you were after it isn't recommended to edit core files in phpBB 3.1. You should request an extension for this otherwise, as 3Di says, you'll have to revisit it next time you update.
"The more connected we get the more alone we become" - Kyle Broflovski©
samuel404
Registered User
Posts: 19
Joined: Wed May 11, 2016 5:44 am

Re: How can I add a custom username restriction settings?

Post by samuel404 »

Mick wrote:
3Di wrote:Let's see you the next phpBB update?
Indeed.

@OP: While you seem to have the fix you were after it isn't recommended to edit core files in phpBB 3.1. You should request an extension for this otherwise, as 3Di says, you'll have to revisit it next time you update.
Okay, I'll request one.
Locked

Return to “[3.1.x] Support Forum”