I'm working in Umbraco 4.0.2 (I believe) and no little to nothing about XSLT; thus - I've been attempting to create a custom user control in C# which retrieves the Member Groups (in general) and/or specifically retrieves the Member Groups of a speficied (logged in) user.
The code I have come up with is ... pretty much nothing, so I've taken it back to "int i = CurrentMemberId();" and started hunting for a potential solution that someone else may have done elsewhere. I've found nothing & hence the post.
This is a method for XSLT that I wrote a long long time ago.. Should get you started.
public static XPathNodeIterator GetMemberGroupsForMember(int memberId) { Member m = new Member(memberId); XmlDocument d = new XmlDocument(); XmlElement g = d.CreateElement("groups");
foreach (int i in m.Groups.Keys) { MemberGroup mg = new MemberGroup(i); XmlElement e = d.CreateElement("group"); XmlAttribute a = d.CreateAttribute("id"); a.Value = mg.Id.ToString(); e.Attributes.Append(a); e.InnerText = mg.Text; g.AppendChild(e); } d.AppendChild(g); return d.CreateNavigator().Select("/groups"); }
if (HttpContext.Current.User.Identity.IsAuthenticated) { int memberId = CurrentMemberId(); string[] roles = Roles.GetRolesForUser(HttpContext.Current.User.Identity.Name);
for (int i = 0; i < roles.Length; i++) { txtLoggedIn.Text += roles[i]; }
} else { txtLoggedIn.Text = "Please Log in"; }
"Roles" actually got me exactly what I needed. I'm throwing in a snippet that kicks out Member Group names for grins in case someone needs it. Very good start for me, so thank you guys for the input! It helped immensly.
Retrieving all Member Groups for Logged In User
I'm working in Umbraco 4.0.2 (I believe) and no little to nothing about XSLT; thus - I've been attempting to create a custom user control in C# which retrieves the Member Groups (in general) and/or specifically retrieves the Member Groups of a speficied (logged in) user.
The code I have come up with is ... pretty much nothing, so I've taken it back to "int i = CurrentMemberId();" and started hunting for a potential solution that someone else may have done elsewhere. I've found nothing & hence the post.
In .umbracoyou can use asp.net mebership stuff....so you should be able to get all roles for a user like Roles.GetRolesForUser(User.Identity.Name)
This is a method for XSLT that I wrote a long long time ago.. Should get you started.
For reference :
"Roles" actually got me exactly what I needed. I'm throwing in a snippet that kicks out Member Group names for grins in case someone needs it. Very good start for me, so thank you guys for the input! It helped immensly.
is working on a reply...