Page 1 of 1

How can I add a custom username restriction settings?

Posted: Sun Jun 05, 2016 4:24 am
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?

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

Posted: Sun Jun 05, 2016 4:53 am
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.

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

Posted: Sun Jun 05, 2016 9:21 am
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.

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

Posted: Mon Jun 06, 2016 9:00 am
by samuel404
Someone help me please, I really needed this.

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

Posted: Mon Jun 06, 2016 9:16 am
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',

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

Posted: Tue Jun 07, 2016 1:08 am
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.

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

Posted: Tue Jun 07, 2016 1:12 am
by 3Di
Let's see you the next phpBB update?

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

Posted: Tue Jun 07, 2016 9:21 am
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.

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

Posted: Thu Jun 09, 2016 2:57 am
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.