Comment approval

Oct 25, 2010 at 10:22 PM

We need to have manual comment approval.  The ideal situation would be approving by clicking on the "Approve" link included in the email sent to the moderator.  The only problem is that the moderator (admin), needs to be logged in for this to work.  The comment does not get approved and nothing happens if the moderator is not logged in.  Is this the way it's supposed to work?  If not, how to make it work if not logged in?


Oct 26, 2010 at 1:24 AM
Edited Oct 26, 2010 at 1:25 AM

In the User Controls folder is a file named CommentView.ascx.cs.  In there, in the Page_Load event, you'll see the code below.  Except, I added new code in there (marked with comments).  Add that new block of code to your file.  With this code, if the person clicks on the approval link in the email, and they are not already logged in, it'll take them to the login page.  Once they login, it'll return them to the original URL which will automatically approve the comment.

// *** NEW CODE BEGIN ***
if (!Page.User.Identity.IsAuthenticated)
	if (Request.QueryString["deletecomment"] != null ||
		Request.QueryString["deletecommentandchildren"] != null ||
		!string.IsNullOrEmpty(Request.QueryString["approvecomment"]) ||
// *** NEW CODE END ***

if (Page.User.Identity.IsAuthenticated)
	if (Request.QueryString["deletecomment"] != null)

	if (Request.QueryString["deletecommentandchildren"] != null)

	if (!string.IsNullOrEmpty(Request.QueryString["approvecomment"]))

	if (!string.IsNullOrEmpty(Request.QueryString["approveallcomments"]))

Oct 26, 2010 at 5:50 PM

Ben, thanks for the reply and code.  It works as you said.

On a similar note, is there a way to allow someone other than the Admin approve comments?  I don't want to give the person who will be moderating comments all of the Admin access.  It seems like there should be another role or something for this purpose.  Is this on the drawing board?

By the way, BlogEngine is very cool and I appreciate all of the effort the dev team has put into it, especially since it is free.

Oct 27, 2010 at 4:57 AM

There is the Editor role.  I think if the person who receives the email is an editor, he can approve the comments.  It may be that the Editor needs to be the author of the post he is approving the comments for, but glancing at the code, I don't think that is required (untested though).  An editor can do certain things in BE, but doesn't have full control like an admin has.

Oct 27, 2010 at 11:43 PM

You are correct.  I created an editor and added a post, then a test comment while signed out.  I received the notification email about the comment and it did have the "approve" link in there, so for that issue, I'm set.

Thanks again.