Hi,
you could add following method and call it from groupEditElem_OnSaved event in file CMSModules\Groups\Tools\Group_New.aspx.cs:
protected void addRoleToGroup()
{
RoleInfo role = new RoleInfo();
// Set RoleInfo properties except RoleID
role.RoleName = "CMSDeskAdmin";
role.DisplayName = "CMSDeskAdmin";
role.Description = "some description...";
role.SiteID = CMS.CMSHelper.CMSContext.CurrentSite.SiteID;
role.RoleGroupID = this.groupEditElem.GroupID;
role.RoleIsGroupAdministrator = true;
// check if the role name is unique in the given site
if (!CMS.SiteProvider.RoleInfoProvider.RoleExists(role.RoleName, CMS.CMSHelper.CMSContext.CurrentSite.SiteName))
{
// Insert new RoleInfo for current site
CMS.SiteProvider.RoleInfoProvider.SetRoleInfo(role);
}
else
{
// Role with the same name already exists in specified site
role = CMS.SiteProvider.RoleInfoProvider.GetRoleInfo("CMSDeskAdmin", CMS.CMSHelper.CMSContext.CurrentSiteName);
//checks if role is not null and if it is not related to another group
if ((role != null) && (role.RoleGroupID ==0))
{
// Make some changes
role.RoleGroupID = this.groupEditElem.GroupID;
role.RoleIsGroupAdministrator = true;
// Update the role
CMS.SiteProvider.RoleInfoProvider.SetRoleInfo(role);
}
}
}
This way role is added to appropriate group after the group is created.
Best regards,
Ivana Tomanickova