I haven't seen anything out there, but it should not be hard to program this using member.AddGroup(int ID) and doing a umbraco.cms.businesslogic.member.MemberGroup.GetAll
Im not sure if there is a user control to do that but its pretty easy to build your own. There is plenty of code around to build the two listboxes and the code to move items between here is a link that may help with the interface.
In terms of what you need to do with your codebind for adding a member to a selected group you would do something like this to loop through the listbox containing the selected groups and add them.
Member m = Member.GetMemberFromEmail(Email); //or however you want to get your member. foreach(ListItem li in SelectedGroups.Items){ m.AddGroup(MemberGroup.GetByName(li.Text).Id); //where the text property contains the name of the group }
Member and MemberGroup is contained in umbraco.cms.businesslogic.member
Thanx for your reply. I'm familar with the techniques and API you mentioned, but I don't want to invent the wheel again. But if its not part of core or there is a package that fits, then I have to make one myself.
Just digged into the editMember.aspx.cs code at core, and discovered how it was done there.
The umbraco.controls.DualSelectBox is easy to use when such a control needed. Then I just "borrowed" the portion of code i needed
controls.DualSelectbox _memberGroups = new controls.DualSelectbox(); _memberGroups.ID = "Membergroups"; _memberGroups.Width = 175; string selectedMembers = ""; foreach(string role in Roles.GetAllRoles()) { // if a role starts with __umbracoRole we won't show it as it's an internal role used for public access if (!role.StartsWith("__umbracoRole")) { ListItem li = new ListItem(role); if (!IsPostBack) {
if (Roles.IsUserInRole(m_Member.UserName, role)) selectedMembers += role + ","; } _memberGroups.Items.Add(li); } } _memberGroups.Value = selectedMembers;
MemberGroup control
Is the membergroup control (used on properties on member tabs) or similar available in a way that can be used in a custom usercontrol?
I cant find it as datatype/rendercontrol nor in umbraco.editorcontrol namespace
I work on a memberprofile usercontrol, where it should be possible to add/remove members from membergroups
Thanx in advantage!
Martin
I haven't seen anything out there, but it should not be hard to program this using member.AddGroup(int ID) and doing a umbraco.cms.businesslogic.member.MemberGroup.GetAll
Hi martin
Im not sure if there is a user control to do that but its pretty easy to build your own. There is plenty of code around to build the two listboxes and the code to move items between here is a link that may help with the interface.
In terms of what you need to do with your codebind for adding a member to a selected group you would do something like this to loop through the listbox containing the selected groups and add them.
Member and MemberGroup is contained in umbraco.cms.businesslogic.member
Hope that helps
Peter,
Thanx for your reply. I'm familar with the techniques and API you mentioned, but I don't want to invent the wheel again. But if its not part of core or there is a package that fits, then I have to make one myself.
Martin
Just digged into the editMember.aspx.cs code at core, and discovered how it was done there.
The umbraco.controls.DualSelectBox is easy to use when such a control needed. Then I just "borrowed" the portion of code i needed
Thanks for posting the solution, very handy to have an easy reference for future use.
Thanks for sharing the solution.
is working on a reply...