I want to get the current users language setting in the back office, for use with CultureInfo.
Currently I am trying this:
var user = userService.GetUserById(userId); userName = user.Name; userLanguage = user.Language;
But I am uncertain what values to expect from user.Language? Finding it hard to find any good documentation for userService. Any help much appreciated :)
So I gave it another try now after working on some other stuff for a while. I made a static helper class with a using statement for Umbraco.Web, and I try to get the user like this:
var user = UmbracoContext.Current.Security.CurrentUser;
public static IMember GetCurrentMember()
{
var membershipUser = Membership.GetUser();
if (membershipUser == null)
{
return null;
}
var user = membershipUser.UserName;
var service = new MemberService(new RepositoryFactory(), new MemberGroupService(new RepositoryFactory()));
return service.GetByUsername(user);
}
Getting the user language
I want to get the current users language setting in the back office, for use with CultureInfo.
Currently I am trying this:
But I am uncertain what values to expect from user.Language? Finding it hard to find any good documentation for userService. Any help much appreciated :)
Hi Johann and welcome to our :-),
I am thinking that this thread can help you https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/60193-Getting-Current-Backend-User
Hope this helps,
/Dennis
Hi Dennis, thanks! :)
So I gave it another try now after working on some other stuff for a while. I made a static helper class with a using statement for Umbraco.Web, and I try to get the user like this:
...which returns null.
Am I missing something?
Hi Johann,
We are using code this method:
Thanks, Alex
is working on a reply...