Only registered users can comment on post

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Feb 20, 2010 at 11:45 AM
Edited Feb 20, 2010 at 11:45 AM

Hi

This is great solution (version 1.6)! Congratulations to the team.

 I am integrating a blog into an existing site which already has members who have registered
elsewhere on the main site.

The idea would be that only these registered users can post comments (or will see an option to
to post a comment)

I am thinking of having comments disabled by default in admin, and turning them on in the
default.aspx page load event if a logged-in cookie is set .

Is there a single place where this can be done that will stick for the entire user session?

Maybe it would be better to enable by default and then disable on page load in the absence of logged-in
cookie?

I am sure someone has done this already, and I would be grateful for any help, to avoid reinventing
the wheel.

Thanks

Clive

Coordinator
Feb 20, 2010 at 6:12 PM

In the User Controls folder, there is a file named CommentView.ascx.cs.  This is the file that determines whether the Comment Form is displayed.  There is already some code in there that checks BlogSettings.Instance.IsCommentsEnabled and turns the Comment Form "on" or "off" depending on that setting.  It turns it "off" by making "phAddComment" not visible.  So you could add code in that spot to check for a cookie and turn phAddComment "on" or "off" depending on the result of the cookie check.