How to avoid that deleting content deletes related comments and replies?

Hi all,

I'm maybe missing some thread here but after searching I didn't find anything useful.

We have a major problem as in this topic's subject. Is there a plugin to replace deleted content (any kind of content, initial or comment or reply) with a message like "This content has been deleted by its owner" to avoid that, for example, deleting first discussion's post also deletes all comments and replies? I think this would also be useful for those who have linked to that specific content not to be confused when not finding it anmore.

Cheers

M

  • Hi Michele,

    sorry to say, but I don't think such a plugin exists.

    A simple way could be to user the 'delete', 'object' event of Elgg to interfere with deletion of content, to check if it's a content type that a user should not be allowed to delete and then replace the content text with the info text.

    For example for comments:

    <?php
    
    elgg_register_event_handler('init','system','delete_replacement_init');
    
    function delete_replacement_init() {
        elgg_register_event_handler('delete','object', 'delete_replacement_object', 499);
        elgg_register_event_handler('delete','entity', 'delete_replacement_object', 499);
    }
    
    function delete_replacement_object($event, $object_type, $object) {
    
        if ($event == 'delete' && !elgg_is_admin_logged_in()) {
            if ($object->getSubtype() == 'comment') {;
                $object->description = "This comment has been removed by the member who had posted it.";
                $object->save();
                return false;
            }
        }
    
        return true;
    }

    If a normal user deletes his comment the replacement will happen. If an admin deletes a comment it will get deleted for real.

    A bit an ugly thing is that the user will get an error message that the comment couldn't get deleted. On the one hand, this is true. On the other hand, nothing wrong has happened because the deletion as such is not intended. But maybe it's enough to just change the text of the error message (language string 'generic_comment:notdeleted') to give a proper explanation.

    Enhancing the code to deal with deletion of other type of content should be straightforward. It's just necessary to figure out the subtype of the content and to see which metadata name is used to save the content text (that would need to be changed then). It should work for text-only content type (comment, blogs, discussions, discussion replies). But I guess it won't be as easy if there are more complex data structures involved (several fields, uploaded files involved etc.).

    Greetings,

    iionly

  • Thank you very much for replying iionly!

    Actually I think this should be something to consider for Elgg because it could be cause of legal issues. I mean, users should have total control on their content while now somebody else is able to make others' comments/replies disappear because deleting his main object type (ie. a discussion topic).

    If a normal user deletes his comment the replacement will happen. If an admin deletes a comment it will get deleted for real.

    Technically nice but not sure legally. IMHO if a user deletes a content it has to be deleted for real and, to avoid the issue mentioned above, replaced by a standard sentence "Content deleted by owner" while keeping related content (comments, replies, etc.) owned by others.

    Cheers!

    M

  • It's not technically possible, and I wouldn't want it to be technically possible in Elgg. It will create a massive headache and overhead without providing no real benefit other than being able to read out of context comments on content that has been deleted.
    For example, what would happen if a user is deleted? Or a group? We already have enough overhead with comments, and singling them out for additional deletion logic doesn't make sense to me from a maintainer perspective.

  • I understand Ismayil but legal issues arose on my side for example and shouldn't be underestimated in my opinion but of course I now understand this is not technically easy to accomplish.

    Basically I was sharing my bad experience so to avoid it to others :)

    More details: a user deleted a lot of discussion threads he started, also in groups, to which important comments were added so many others got extremely upset with him but then also with the platform because in their opinion while the right to delete initial post was granted, not the same right (keep own comments) was granted to others commenting.

  • I'm not sure if there are legal issues in either case, i.e. deleting responses from other users on deletion of the initial content or the other way round in not allowing deletion of (to some extend public) content at all. It's different with personal information (profile page stuff) which a user can request to be deleted. But the other stuff someone posts could be seen as some kind of at least shared ownership by the user and the site / site admin. But I also guess it depends on what might have been written about that in the site's terms (and it might be different in different countries depending on local law). Vanishing responses on deletion of the post they were made on shouldn't come as total surprise. It's annoying for sure but I would think that it the way it works on ANY forum or social network.

    With the code I posted above the original content (in this case the comment's content) is deleted in any case. Just in the case of deletion by the owner the comment entity is still kept - but with replaced content - and still owned by the original poster. In case of comments it wouldn't be possible to add the info by other means as you wouldn't know to which deleted commented the info would refer to and it's also important to have the info in the right order within the remaining comments or you would have even more difficulties understanding a later comment referring the deleted comment (as it might be hard enough already in some cases to understand a response without the original comment).

    I guess the ownership issue could be solved by creating a "garbage" user which gets all "deleted" content assigned to that the original owner wants to delete (e.g. transfer of groups also as fallback and of course replaced info entities showing the deletion texts instead of the original content).

    I would also think that it's not good to add such functionality to Elgg core. It can be achieved by a plugin. And as I already mentioned, some customizations might be necessary on different sites depending on the plugins used anyway.