SOLVED: Possible? edit restricted username spacers

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
brenwa
Registered User
Posts: 52
Joined: Thu Oct 06, 2022 10:47 pm

SOLVED: Possible? edit restricted username spacers

Post by brenwa »

located in user registration settings I would like to edit the spacers allowed in the setting below

DEFAULT:
Limit username chars:
Restrict type of characters that may be used in usernames, spacers are: space, -, +, _, [ and ].

I would like to limit it to just a dash - and underscore _

I realize I might have to get into the database, but Im hoping its somewhere in the language or other easy to edit file

Thank you for your help :)
Last edited by Mick on Fri Feb 09, 2024 7:55 pm, edited 2 times in total.
Reason: Solved.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53514
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Possible? edit restricted username spacers

Post by Brf »

includes/functions_user.php on lines 1772 and 1780 you should be able to edit the regex to remove characters you do not want.
brenwa
Registered User
Posts: 52
Joined: Thu Oct 06, 2022 10:47 pm

Re: Possible? edit restricted username spacers

Post by brenwa »

thank you that is very helpful (I am not familiar enough with this to know exactly what to remove)

to edit this:

Code: Select all

case 'USERNAME_LETTER_NUM_SPACERS':
			$regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+';
to limit the spacers to only - and _

what would I remove from

Code: Select all

$regex = '[-\]_+ [\p{Lu}\p{Ll}\p{N}]+';
thank you :)
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53514
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Possible? edit restricted username spacers

Post by Brf »

Try

Code: Select all

$regex = '[-_\p{Lu}\p{Ll}\p{N}]+';
brenwa
Registered User
Posts: 52
Joined: Thu Oct 06, 2022 10:47 pm

Re: Possible? edit restricted username spacers

Post by brenwa »

Code: Select all

$regex = '[-_\p{Lu}\p{Ll}\p{N}]+';
that worked great thank you

one last question
where would I edit the text displaying under username: on the registration form
and use alphanumeric, space or -+_[] characters.
I need to remove space + and []

thank you
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53514
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Possible? edit restricted username spacers

Post by Brf »

All of the text you see is in the language files. In this case they are in /language/en/ucp.php:

Code: Select all

	'USERNAME_ALPHA_ONLY_EXPLAIN'	=> 'Username must be between %1$s and %2$s long and use only alphanumeric characters.',
	'USERNAME_ALPHA_SPACERS_EXPLAIN'=> 'Username must be between %1$s and %2$s long and use alphanumeric, space or -+_[] characters.',
	'USERNAME_ASCII_EXPLAIN'		=> 'Username must be between %1$s and %2$s long and use only ASCII characters, so no special symbols.',
	'USERNAME_LETTER_NUM_EXPLAIN'	=> 'Username must be between %1$s and %2$s long and use only letter or number characters.',
	'USERNAME_LETTER_NUM_SPACERS_EXPLAIN'=> 'Username must be between %1$s and %2$s long and use letter, number, space or -+_[] characters.',
brenwa
Registered User
Posts: 52
Joined: Thu Oct 06, 2022 10:47 pm

Re: SOLVED: Possible? edit restricted username spacers

Post by brenwa »

thank you for all the help :)

Return to “phpBB Custom Coding”