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:

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?

Next article

Delete comments