Gossamer Forum
Home : Products : Others : Gossamer Community :

user signup, non-english characters

Quote Reply
user signup, non-english characters
The site is set to UTF-8, and non-english characters work fine.


However, when users signup using GT Community with their name in other non-english characters, they get the following error:


Username must be at least 3 characters long and consist of only letters and numbers.


What do I need to do to permit non-english characters in user names?


Thanks!
Quote Reply
Re: [tora] user signup, non-english characters In reply to
Hi,

Mmm I'm not too sure. You could take a look at the community.conf file, and look at the "signup regex" rule in there. My guess is that it only allows a-zA-Z0-9-_ and spaces. I'm not too sure if it will let you add utf8 in (unless maybe you change the .conf file to "UTF8 without BOM" format)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] user signup, non-english characters In reply to
Thanks, Andy.

In the community.conf file I changed

'signup_username_regex' => '^[\w\-\.]{3,15}$',

to

'signup_username_regex' => '^[\p{L}\p{M}\p{N}\-\.]{3,15}$',


but I still get the error message.


I do not know what you mean by "UTF8 without BOM" format.
Quote Reply
Re: [tora] user signup, non-english characters In reply to
Hi,

If you are doing it with \p{L}, then you don't need to worry about converting the .conf file into BOM :)

If you look in private/Community/User.pm, you should see:

Code:
sub cuser_un_isinvalid {
# -------------------------------------------------------------------
my $username = shift;
(defined $username and length $username) or return 1;
if (defined $CFG->{signup_username_regex} and length $CFG->{signup_username_regex}) {
return ($username =~ /$CFG->{signup_username_regex}/) ? 0 : 1;
}
return 1;
}


Can you tweak it a bit to see some debug:

Code:
sub cuser_un_isinvalid {
# -------------------------------------------------------------------
my $username = shift;
(defined $username and length $username) or return 1;
print $IN->header;
print qq|$username =~ /$CFG->{signup_username_regex}/\n|;
if (defined $CFG->{signup_username_regex} and length $CFG->{signup_username_regex}) {
return ($username =~ /$CFG->{signup_username_regex}/) ? 0 : 1;
}
return 1;
}

Then see what it gives you when you try and signup again.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] user signup, non-english characters In reply to
Thanks, Andy.

I copy/pasted the two extra lines you suggested, so the code now looks as below. Unfortuantely, I still get the same error message.

I'd greatly appreciate more ideas.

Code:
sub cuser_un_isinvalid {
# -------------------------------------------------------------------
my $username = shift;
(defined $username and length $username) or return 1;
print $IN->header;
print qq|$username =~ /$CFG->{signup_username_regex}/\n|;
if (defined $CFG->{signup_username_regex} and length $CFG->{signup_username_regex}) {
return ($username =~ /$CFG->{signup_username_regex}/) ? 0 : 1;
}
return 1;
}
Quote Reply
Re: [tora] user signup, non-english characters In reply to
Hi,

Sorry, its a bit tricky as I don't have any active GComm setups on any of my sites. Only client ones, and I can't start playing with those :)

If you are happy to send over FTP details, I can take a quick look for you tomorrow (email me on andy.newby@gmail.com )

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] user signup, non-english characters In reply to
Thanks, Andy, for your offer, but it may not be necessary.
I just realised the code you gave was for debugging. Blush Way too much hurrying yesterday!!

Trying to sign up with the Russian name Yanna (Янна) gives the error message
  • Username must be at least 3 characters long and consist of only letters and numbers.


At the top of the screen, from your code, I get:

Янна =~ /^[\p{L}\p{M}\p{N}\-\.]{3,15}$/


Thanks so much for your help and patience!

----- I just previewed this post and I see that my Russian letters appear as Янна It seems this forum is not set for multiple scripts. On my site the letters are correct, though.
Quote Reply
Re: [tora] user signup, non-english characters In reply to
Hi,

Mmm I'm not sure - it looks like it should work:

Code:
use utf8;

my $test = q|Яна|;

if ($test =~ /^[\p{L}\p{M}\p{N}\-\.]{3,15}$/) {
print "All good\n"
} else {
print "BAD\n"
}

I get:

Quote:
PS C:\Users\Andy\test_uppercase> perl .\signup.pl
All good

I'm not too sure why it would fail on the signup process :/

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] user signup, non-english characters In reply to
Thanks, Andy. I can look at this tonight.

Your code gave me an idea.

The GT Community admin does not have a way to make UTF-8 the default. In the templates I made it the default, so they look OK on the screen. But maybe the perl code does not recognise it. Therefore perhaps I have to put

Code:
use utf8;

somewhere in the perl code.

If so, where would you suggest? and should it be in several places?
Quote Reply
Re: [tora] user signup, non-english characters In reply to
Hi,

All this bit does:

Code:
use utf8;

is allow for you to use actual utf8 in the file itself.

I guess its possible the form isn't sending correctly. You could try:

Code:
<form ... accept-charset="utf-8">

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] user signup, non-english characters In reply to
Seemed like a good idea, but it did not work.

I tried both
Code:
<form action="<%path_cgi_url%>" method="post" accept-charset="utf-8">
and
Code:
<form action="<%path_cgi_url%>" method="post" accept-charset="UTF-8">
You're sure there's nothing that needs to go into the perl code?
Quote Reply
Re: [tora] user signup, non-english characters In reply to
Hi,

Mmm ok. It should work out of the box, so I'm not sure whats going on. As I said, it's a bit hard to test without a working install (and I don't have time to set one up). If you are able to send over logins, I can take a quick look for you.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!