You can create comments programmatically using the Comments API. To create a comment, you use the CreateComment method of ICommentService interface.
You can create comments for any content item. In this example, you create a comment to a News item. NOTE: When creating the comment, you must assign it to the Live version of the News item. For more information about news, see For developers: News.
To create the comment:
NOTE: The method requires a thread proxy as a parameter.
You may also need to set the key of the thread proxy and language. The thread key is formed by the Live ID of the News item and the current culture, appended by an underscore.
NOTE: The method above requires a group proxy as a parameter.
The group proxy requires a name, description and author. The author can be either a user retrieved using the AuthorProxy (you create the author proxy in next step), or the currently authenticated user.
Sitefinity CMS also enables you to associate the new comment with existing user in case the comment author is already authenticated on your site.
Use the code below to create a News comment with the specified ID, Message, Author name, email, and IP:
To change the status of a comment, for example set a comment as Spam, you set the value of the Status property to the StatusConstants.Spam. The following example demonstrates creation of a Spam comment.
NOTE: The StatusConstants is an enumeration with four possible values: Published, WaitingForApproval, Spam, and Hidden.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
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.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important