Copied to clipboard

Flag this post as spam?

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


  • Andreas 8 posts 28 karma points
    Jun 25, 2012 @ 12:13
    Andreas
    0

    Member.GetCurrentMember()

    Hello,

     

    Easy question, Im using Member.GetCurrentMember().getProperties, I want to place those in a nice way in textboxes each [0], [1] property ofc, is there some neat way to do this?

  • Sjors Pals 617 posts 270 karma points
    Jun 25, 2012 @ 12:16
    Sjors Pals
    0

    Are you using XSLT, Razor, or a Usercontrol?

  • Sjors Pals 617 posts 270 karma points
    Jun 25, 2012 @ 12:17
  • Andreas 8 posts 28 karma points
    Jun 25, 2012 @ 12:25
    Andreas
    0

    Im using Razor, I would like to tell like [0] goes to textbox1, [1] goes to textbox 2.

     

    And I want to use getProperties, in there I get [0] with info and [1],[2] up to 7 those I want to place in different textboxes.

  • Andreas 8 posts 28 karma points
    Jun 25, 2012 @ 12:34
    Andreas
    0

    I guess I need to use things like .All or .ToList and such, I did have a great example code for that for a old project, but I cant access that right now.

     

    Its custom properties, not the default ones, in getProperty I find the default, but if I go 

     

    Member m = Member.GetCurrentMember();

    and I do m.getProperties <- there I find my custom made properties like "Company" and so on, those Id like to present in textboxes.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 25, 2012 @ 12:50
    Jeroen Breuer
    0

    I convert the member properties to my own object and select those in Razor: http://our.umbraco.org/forum/developers/extending-umbraco/27626-Accessing-Member-Information?p=0#comment103415. Might be an easier way to do it.

    Jeroen

  • Andreas 8 posts 28 karma points
    Jun 25, 2012 @ 13:02
    Andreas
    0

    Well, that information is just the default data. I have made a custom tab, which I find at

     

    Member.GetCurrentMember.getProperties (not getProperty, here I find the default value like when account was created, username and so on), but in getProperties I find my custom made which is 

    [0]

    [1]

    [2]  

    all the way to 7. and in those they have a field called "Value", which has my correct value which I like to place in textbox.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 25, 2012 @ 13:07
    Jeroen Breuer
    0

    If you have a custom property you can also use getProperty for that. For example: Member.GetCurrentMember().getProperty("customAlias"). In the example I posted the last property name is "bedrijfsnaam". That is the name of a custom property on a custom tab.

    Jeroen

  • Andreas 8 posts 28 karma points
    Jun 25, 2012 @ 14:55
    Andreas
    0

    Great thanks, it works just fine!

     

    By the way, you been using same method but for edit your own login?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jun 25, 2012 @ 15:00
    Jeroen Breuer
    0

    Yes you can use the member API to update a member too. Here are some methods that I'm using:

    /// <summary>
    /// Reset the password of a member.
    /// </summary>
    /// <param name="loginName"></param>
    /// <param name="newPassword"></param>
    /// <returns></returns>
    public MemberData ResetPassword(string loginName, out string newPassword)
    {
        //Get the member.
        Member member = Member.GetMemberFromLoginName(loginName);
    
        if (member == null)
        {
            //Throw an exception if the member is not found.
            throw new MessageException(library.GetDictionaryItem("Login.MemberNotFound"));
        }
    
        //Generate the new password.
        newPassword = Membership.GeneratePassword(6, 1);
    
        //Change the member password.
        member.Password = newPassword;
    
        //Return the member.
        return GetMember(member.Id);
    }
    
    /// <summary>
    /// Change the login name (email) of a member.
    /// </summary>
    /// <param name="memberId"></param>
    /// <param name="loginName"></param>
    public void UpdateLoginName(int memberId, string loginName)
    {
        //Get the member.
        Member member = new Member(memberId);
    
        //Change the login name.
        member.LoginName = loginName;
        member.Email = loginName;
    
        //Save the member to update the xml.
        member.Save();
        member.XmlGenerate(new XmlDocument());
    }
    
    /// <summary>
    /// Change the password of a member.
    /// </summary>
    /// <param name="memberId"></param>
    /// <param name="newPassword"></param>
    public void ChangePassword(int memberId, string newPassword)
    {
        //Get the member.
        Member member = new Member(memberId);
    
        //Change the member password.
        member.Password = newPassword;
    }
    
    /// <summary>
    /// Update the if a member already has ordered.
    /// </summary>
    /// <param name="memberData"></param>
    public void UpdatePlacedOrder(MemberData memberData)
    {
        Member member = new Member(memberData.MemberId);
        member.getProperty("placedOrder").Value = memberData.PlacedOrder ? 1 : 0;
    
        //Save the member to update the xml.
        member.Save();
        member.XmlGenerate(new XmlDocument());
    }

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft