Modifying and creating groups

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following sample code shows how you can modify the Display name of an existing group:

 

[C#]

 

using CMS.Community;

 

...

 

        // Get group object by GroupID

        GroupInfo gi = GroupInfoProvider.GetGroupInfo(1);

 

        // Change group display name

        gi.GroupDisplayName = gi.GroupDisplayName + "_Updated";

 

        // Save object

        GroupInfoProvider.SetGroupInfo(gi);

 

The following sample code shows how you can create a new group and add it to the system:

 

[C#]

 

using System;

using CMS.Community;

using CMS.SiteProvider;

using CMS.UIControls;

using CMS.CMSHelper;

 

...

 

        // Create empty group object

        GroupInfo gi = new GroupInfo();

 

        // Set properties

        gi.GroupDisplayName = "New group";

        gi.GroupName = "NewGroup";

        gi.GroupSiteID = 2;

        gi.GroupDescription = "";

        gi.GroupApproveMembers = GroupApproveMembersEnum.AnyoneCanJoin;

        gi.GroupAccess = SecurityAccessEnum.AllUsers;

        gi.GroupApproved = true;

        gi.GroupApprovedByUserID = CurrentUser.UserID;

        gi.GroupCreatedByUserID = CurrentUser.UserID;

        gi.AllowCreate = SecurityAccessEnum.GroupMembers;

        gi.AllowDelete = SecurityAccessEnum.GroupMembers;

        gi.AllowModify = SecurityAccessEnum.GroupMembers;

        gi.GroupNodeGUID = Guid.Empty;

 

        // Save object to database

        GroupInfoProvider.SetGroupInfo(gi);

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_modifying_and_creating_groups.htm