I am not able to explicitly set the portal user's timezone or language with the Site.createPortalUser() method. My apex controller sets those fields as shown below, but when I execute the Site.createPortalUser() method, the newly created User inherits the Site Guest User's timezone and language. The Site method ignores what my controller code set in those fields.
In the example below, I hardcode the language and timezones. The locale related fields get ignored and overriden by the Site Guest User's locale defaults.
User u = new User(); u.Username = username; u.Email = email; u.CommunityNickname = communityNickname; u.emailencodingkey='UTF-8'; u.languagelocalekey='es'; u.localesidkey='en_BM'; u.timezonesidkey='Pacific/Auckland'; System.debug('user:' + u); String accountId = PORTAL_ACCOUNT_ID; // lastName is a required field on user, but if it isn't specified, we'll default it to the username String userId = Site.createPortalUser(u, accountId, password);
Is there anyway on a Site registration page to let the user set their locale fields (timezone, locale, language)? Is this expected behavior of the Site.createPortalUser() method? If yes, can this please be added to the documentation?