Copied to clipboard

Flag this post as spam?

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


  • Naveed Ali 161 posts 426 karma points
    Jun 04, 2016 @ 20:39
    Naveed Ali
    0

    get member first name

    Hi,

    I am trying to do a simple thing ( so it seems) I want to get the first name of the current user.. The first name is under the member details tab in the umbraco backend.

    I cannot access these properties.

    using v7

    Can someone please help this is what i have so far which just gets the current member username

      @if (Membership.GetUser() != null)
                                {
                                    var Username = Membership.GetUser();
    
    
                                    if (s != null)
                                    {
                                        @Html.Raw("Hello, " + username)
                                    }
    
                                }
    

    Thanks

    Nav

  • Naveed Ali 161 posts 426 karma points
    Jun 04, 2016 @ 20:51
    Naveed Ali
    0

    anyone else wants to do this, this is how:

    @if (Membership.GetUser() != null)
                                    {
                                        var memberShipHelper = new Umbraco.Web.Security.MembershipHelper(Umbraco.Web.UmbracoContext.Current);
                                        var Username = memberShipHelper.GetCurrentMember();
                                       var test = Username.GetPropertyValue("firstName");
    
                                        if (test != null)
                                        {
                                            @Html.Raw("Hello, " + test)
                                        }
    
                                    }
    
  • 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