November Happy Hour will be moved to Thursday December 5th.

Get current users language settings in CMS 12?

Vote:
 

Hi!

In CMS 11 I could get the logged in persons languagesettings usign this:

var profileLanguage = EPiServerProfile.Current.Language;

How is this done in CMS 12? I cannot find anything in the documentation?

Thanks!

/Kristoffer

#267916
Dec 06, 2021 10:43
Vote:
 

I still have not figuerd this on out, anyone?

/Kristoffer

#268436
Dec 15, 2021 21:48
Vote:
 

Hi Kristoffer,

This is how it's done in CMS 12:

// constructor injection...
private readonly IPrincipalAccessor _principalAccessor;
private readonly IUserMembershipService _userMembershipService;

...

var userMembershipInfo = await _userMembershipService.GetUser(_principalAccessor.CurrentName());
var language = userMembershipInfo.Language;

Hope this helps!

#268507
Dec 16, 2021 20:06
Vote:
 

Thanks Dejan!

I guess this should be ok to:

var userMembershipInfo =  _userMembershipService.GetUser(User.Identity.Name);

/Kristoffer

#268510
Edited, Dec 16, 2021 21:09
Vote:
 

Nope, that did not work but yours did. Thanks again!

#268567
Dec 17, 2021 10:06
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.