Extended Characters in Usernames
If you need to use extended characters in usernames, there is a setting under:
Called Allow extended characters in usernames (
You don’t need this if you are using email addresses as usernames (as the @ symbol is allowed) but you might run into a few other edge cases with email addresses:
Emails that are mixed case e.g.
- Example@MoodleTips.com need to be lowercased to email@example.com
- Emails can have other characters such as an apostrophe (e.g. jack.o’firstname.lastname@example.org) and if you want to preserve such characters you’ll need to turn this setting on. Alternatively you can remove such characters from the username.
- Emails might have extended language characters in them which required this setting to be turned on as well if you want to match the username to the email addresse exactly.
Also worth noting is that the
lib/classes/user.php definition uses
PARAM_RAW) anymore in recent versions of moodle. This is used for things like the core user web services. So you will hit invalid parameter exceptions if you specify a username in say mixed case format or with extended characters (and the
extendedusernamechars setting is off).
This can be confusing it seems like you have specified the wrong parameters but what’s happening is that your parameter does not meet the requirements of
PARAM_USERNAME. To see the code used to test
PARAM_USERNAME have a look in
lib/moodlelib.php :: clean_param().