Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Johann Prell 2 posts 22 karma points
    May 08, 2015 @ 14:13
    Johann Prell
    0

    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:

    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 :)

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    May 08, 2015 @ 14:30
    Dennis Aaen
    0

    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

  • Johann Prell 2 posts 22 karma points
    May 15, 2015 @ 14:30
    Johann Prell
    0

    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:

    var user = UmbracoContext.Current.Security.CurrentUser;

    ...which returns null. 

    Am I missing something?

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    May 15, 2015 @ 16:36
    Alex Skrypnyk
    0

    Hi Johann,

    We are using code this method:

            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);
            }
    

    Thanks, Alex

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies