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?
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.
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.
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.
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());
}
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?
Are you using XSLT, Razor, or a Usercontrol?
Here some info which you can use: http://our.umbraco.org/forum/developers/razor/19040-Working-with-members-and-Razor
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.
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.
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
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.
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
Great thanks, it works just fine!
By the way, you been using same method but for edit your own login?
Yes you can use the member API to update a member too. Here are some methods that I'm using:
Jeroen
is working on a reply...