You can set a topic as solution only if you haven't voted it up yet. There should then also be a green icon next to the thumbs. If you allready voted up, the icon is gone and you can't set it as solution anymore. (They're aware of this and it will be fixed so I've heard)
Is there a similar approach to getting user properties? I currently use this membership provider because I want my users to click on an avtivation link I email to them. If they haven't activated themselves, then I don't want to validate them. When they click the link in the email a boolean property called Active is set.
public class CustomMembershipProvider : umbraco.providers.members.UmbracoMembershipProvider
{
public override bool ValidateUser(string username, string password)
{
Member m =Member.GetMemberFromLoginAndEncodedPassword(username, EncodePassword(password));
if (m == null)
return false;
else
{
try
{
if (m.getProperty("active").Value.ToString() == "1")
return true;
else
return false;
}
catch
{
return false;
}
}
}
}
@rasb - You really should be using the ASP.NET Profile Provider for this. I think I'm going to have to get around to doing some info on this as it seems to be a common question.
Long story short (ie - all I've got written yet :P) you can implement a ProfileProvider (MSDN has examples of how to set one up) and then specify the ProfileProvider class to be umbraco.providers.members.UmbracoProfileProvider
How to retrieve a members membergroups?
Hi i did intensively look in the code, but can't find it, is it possible to retrieve all membergroups from a particular member?
Is this what you are looking for?
umbraco.cms.businesslogic.member.MemberGroup.GetAll
Ron
You can also take a look at:
http://forum.umbraco.org/yaf_postst1944_getting-member-attributes-via-xslt.aspx
Ron
I think you you can use something like
Thx got it working,
[code]
protected void btn_Click(object sender, EventArgs e) {
string groups;
umbraco.cms.businesslogic.member.Member m =
umbraco.cms.businesslogic.member.Member.GetMemberFromLoginNameAndPassword(
login.Text, password.Text);
if (m != null)
{
umbraco.cms.businesslogic.member.Member.AddMemberToCache(m);
foreach (MemberGroup mg in MemberGroup.GetAll)
{
if (m.Groups.ContainsKey(mg.Id))
//my code here
lblLogin.Text += "group id=\"" + mg.Id.ToString() + "\" groupName=\"" + mg.Text + "\n";
}
}
else {
lblLogin.Text = "fout";
}
}
[/code]
Thanks for sharing your result. Please select the solution to close the ticket.
When my code is finished, i will post it on the wiki, can someone tell me how i can set the topic as solved?
You can set a topic as solution only if you haven't voted it up yet. There should then also be a green icon next to the thumbs. If you allready voted up, the icon is gone and you can't set it as solution anymore. (They're aware of this and it will be fixed so I've heard)
If you are using Umbraco 4 I would strongly recommend that you use the standard ASP.NET methods to get back the roles. For example you should do this:
This will then go via the umbraco.providers.members.MemberRoleProvider by default, or any custom ASP.NET role provider you choose to implement.
Directly interacting with the Member API is no longer recommended.
Thanks for your advice Slace, will change it in my code :)
Hi Slace,
Is there a similar approach to getting user properties? I currently use this membership provider because I want my users to click on an avtivation link I email to them. If they haven't activated themselves, then I don't want to validate them. When they click the link in the email a boolean property called Active is set.
Could I validate the user using:
And then get the property from the
instead?
/rasb
@rasb - You really should be using the ASP.NET Profile Provider for this. I think I'm going to have to get around to doing some info on this as it seems to be a common question.
Long story short (ie - all I've got written yet :P) you can implement a ProfileProvider (MSDN has examples of how to set one up) and then specify the ProfileProvider class to be umbraco.providers.members.UmbracoProfileProvider
Hi Slace,
I will try to look into ProfileProviders, but since this works for now, I am afraid it is being bumped down the list of priorities :(
But a list of "best practices" on the wiki would be a good idea as you say yourself.
/rasb
I've done a post on the ProfileProvider which I'll put onto the wiki when you are able to upload images onto it! http://www.aaron-powell.com/blog/july-2009/umbraco-member-profiles.aspx is where the info is at the moment
What about the Access class? Is that also deprecated then?
I am thinking of for example checking to see if a node i protected like this:
Is there a way to that through the provider?
/rasb
I'm not sure, I've never looked into the Access class. I'll put that on the cards for tomorrow
is working on a reply...