Modify comments

Sitefinity CMS enables you to modify a comment through the Comments API.

Modify comment by comment key

To modify a comment, for example a comment for a News item, perform the following:

  1. Get an instance of the comments service using the SystemManager's GetCommentsService method.
  2. Get the comment that corresponds to the specified comment Key.
    For more information see Query comments.
  3. Modify the comment.
    After you get the comment, you modify it using the UpdateComment method of the comments service.
    Consider the code sample below:

Mark the status of a comment as Spam

  1. Get an instance of the comments service using the SystemManager's GetCommentsService method.
  2. Get the comment that corresponds to the specified comment Key.
    For more information see Query comments.
  3. To mark a comment as Spam, you set it's status to StatusConstants.Spam. Finally, you modify the comment using the UpdateComment method of the comments service.
      Consider the code sample below:

Mark the status of a comment as Published

  1. Get an instance of the comments service by using the SystemManager's GetCommentsService method.
  2. Get the comment that corresponds to the specified comment Key.
    For more information see Query comments.
  3. Tn order to mark a comment as ham, you need you set it's status to Published.
    You do this by setting the Status property to StatusConstants.Published. Finally, you modify the comment using the UpdateComment method of the comments service.
    Consider the code sample below:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Delete comments