If you need to use extended characters in usernames, there is a setting under Site Administration > Security > Site Policies called Allow extended characters in usernames
By default moodle usernames must be lowercase and are restricted to alphanumeric characters, the underscore, hypen, period and @ symbol.
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. [email protected] need to be lowercased to [email protected]
- Emails can have other characters such as an apostrophe (e.g. jack.o’[email protected]) 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_USERNAME (not 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 follow the definition of PARAM_USERNAME. To see the code used to test PARAM_USERNAME have a look in