Allow users to delete their own blog comments

   —   
By default only a global administrator, blog author, and users with Manage comments permission are able to delete comments on Blog.  What if you would like to allow all users to be able to delete their own comments, but not anyone else's unless they have the manage comments permission?
For this purpose you will need to modify a control of the Blog Post Viewer module: \CMSModules\Blogs\Controls\BlogCommentView.ascx.cs

around line 594 replace the following line:

mBlogComment.ShowDeleteButton = (mBlogProperties.ShowDeleteButton && isUserAuthorized);
    
        
with

if (CurrentUser.UserID == bci.CommentUserID) mBlogComment.ShowDeleteButton = true; else mBlogComment.ShowDeleteButton = (mBlogProperties.ShowDeleteButton && isUserAuthorized);
  
            
and then modify the permissions check, around line 447 replace:

if (!isUserAuthorized) { AccessDenied("cms.blog", "Manage"); }
  

with

if (!CurrentUser.IsAuthenticated()) { AccessDenied("cms.blog", "Manage"); }

-md-


See also: Moderating Comments

Applies to: Kentico CMS 7.x
Share this article on   LinkedIn

Martin Danko

Let me guide you on your journey of success. I will show you how to optimize your content production with Kentico Draft. Check out www.kenticocloud.com