Sitefinity CMS

Deleting Forums Send comments on this topic.
See Also
Developing with Sitefinity > Modules > Modules API > Forums > Forum Items > Deleting Forums

Glossary Item Box

Forums can be deleted in two ways:

  • DeleteForum(IForum forum) - Delete a forum which is passed as parameter
  • DeleteForum(Guid forumID) - Delete a forum with an ID passed as parameter
By deleting the forum, all posts belonging to this forum will be deleted as well.

Delete a forum which is passed as parameter:

DeleteForum(IForum forum) Copy Code
// create new instance of ForumManager
Telerik.Forums.ForumManager forumManager = new Telerik.Forums.ForumManager();
// The GetForums(bool excludeHidden) method returns an object of type IList,
// so we create a list of all forums
IList listOfForums = forumManager.GetForums(false);
if (listOfForums.Count > 0)
{
   
// we get the ID of the first forum
   
Telerik.Forums.IForum firstForum = forumManager.GetForum(((Telerik.Forums.IForum)listOfForums[0]).ID);
   
// we delete the forum
   
forumManager.DeleteForum(firstForum);
}

 

Delete a forum with an ID passed as parameter:

DeleteForum(Guid forumID) Copy Code
// create new instance of ForumManager
Telerik.Forums.ForumManager forumManager = new Telerik.Forums.ForumManager();
// The GetForums(bool excludeHidden) method returns an object of type IList,
// so we create a list of all forums
IList listOfForums = forumManager.GetForums(false);
if (listOfForums.Count > 0)
{
   
// we get the ID of the first forum
   
Telerik.Forums.IForum firstForum = forumManager.GetForum(((Telerik.Forums.IForum)listOfForums[0]).ID);
   Guid firstForumId = firstForum.ID;
   
// we delete the forum by passing its ID
   
forumManager.DeleteForum(firstForumId);
}

 

 

See Also