API Questions on Kentico API.
Version 5.x > API > Delete Users, related BlogPost records deleted but not BlogComment, why? View modes: 
User avatar
Member
Member
Comet Halley - 12/4/2011 4:27:46 PM
   
Delete Users, related BlogPost records deleted but not BlogComment, why?
Hi,

Using v5.5R2.

Step1: Created some User, Let's assume dbo.CMS_User.UserID = 123

Step2: Create some BlogPosts using these users (dbo.CMS_Document.DocumentCreatedByUserID = the UserID created in Step1)

Step 3: Create some Comments for the Blog Posts in Step2
(dbo.Blog_Comment.CommentUserID = same user who owns the BlogPost where the comment belongs to. Which means CommentUserID = 123 in this example.

Step4: Delete UserID 123
CMS.SiteProvider.UserInfoProvider.DeleteUser(123);

Step5: Verification shows: User & all Blog Posts have been deleted.
HOWEVER, the comments created in Step3 still exists. Their value in dbo.Blog_Comment.CommentUserID is just set to NULL.

QUESTION: is it intentional to keep a Blog Comment while the reference data no longer exist? If yes, Is there a way to delete the comments beloning to a User when this user is deleted?

Thanks in advance for any help.

User avatar
Member
Member
Comet Halley - 12/4/2011 4:40:51 PM
   
RE:Delete Users, associated BlogPost and BlogComment NOT deleted why?
Comet Halley wrote:
Step5: Verification shows: User & all Blog Posts have been deleted.
HOWEVER, the comments created in Step3 still exists. Their value in dbo.Blog_Comment.CommentUserID is just set to NULL.

QUESTION: is it intentional to keep a Blog Comment while the reference data no longer exist? If yes, Is there a way to delete the comments beloning to a User when this user is deleted?


EDIT: How to edit my own post?
I made a mistake in the verification. Can you please replace the following portion by this new version:

Step5: Verification shows: User have been deleted.
HOWEVER, the BlogPosts and the Comments created in Step2 and Step3 still exist. Their value in dbo.CMS_Document.DocumentCreatedByUserID and dbo.Blog_Comment.CommentUserID is just set to NULL.


QUESTION:
is it intentional to keep BlogPosts and BlogComments while the reference User no longer exist? If yes, Is there a way to delete the BlogPosts and Blog comments belonging to a User when this user is deleted?

Thanks.


User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/15/2011 8:44:00 AM
   
RE:Delete Users, associated BlogPost and BlogComment NOT deleted why?
Hi,

yes it is default behavior.

For example if user writes some comments which may help others or create a blog post with the interesting information - it would not be good it these would be deleted.

If you need to change this behavior, you can create a custom event handler, which deletes blog post documents and comments (CMS.BlogComments table).

How to create a custom event handler is described here:
Custom event handler

Best regards,
Ivana Tomanickova