function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Drew1815Drew1815 

Setting time zone and language with Site.createPortalUser()

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?

 

Thanks 

 

 

BulentBulent
You are correct. We are defaulting to site user values. We will log a bug and fix this. 
ssbreesessbreese

Has this been fixed? 

 

Also, is there a way to pass the locale as part of invoking SFDC ideas since the user does not need to sign in until they actually create, vote, or comment on an idea.  In other words, SFDC does not know who the user is until after the user accesses SFDC, yet the user wants to see the SFDC ideas default page in french.