Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

hide_delete_comment()

Description

Hide or delete a comment or annotation. Comments will be hidden where they have comments below them.
If the comment has no comments below it will be deleted. Trees with all hidden comments will also be deleted.
Option to disable deletion / hiding of comments created as annotations e.g. to prevent API use.

Parameters

ColumnTypeDefaultDescription
$comment_to_hide int Reference of the comment to be deleted / hidden.
$allow_annotations bool true: bool { if !checkPerm"o" Should comments created by annotations be deleted / hidden.

Return

bool True if successful else false.

Location

include/comment_functions.php lines 573 to 608

Definition

 
function hide_delete_comment(int $comment_to_hide$allow_annotations true): bool
{
    if (!
checkPerm("o")) {
        return 
false;
    }

    
$root find_root_comment($comment_to_hide);
    
$linked_annotation getAnnotation(ps_value(
        
'SELECT annotation AS `value` FROM `comment` WHERE ref = ?',
        [
'i'$comment_to_hide],
        
0
    
));

    if (
$linked_annotation !== [] && !$allow_annotations) {
        return 
false;
    }

    
// $request_ctx originates from pages/ajax/annotations.php
    
if ($linked_annotation !== [] && deleteAnnotation($linked_annotation$GLOBALS['request_ctx'] ?? [])) {
        
$comment_update_extra_cols ', annotation = null';
    } else {
        
$comment_update_extra_cols '';
    }

    
// Does this comment have any child comments?
    
if (ps_value("SELECT ref AS value FROM comment WHERE ref_parent = ?", array("i",$comment_to_hide), '') != '') {
        
ps_query("UPDATE `comment` SET hide = 1{$comment_update_extra_cols} WHERE ref = ?", ['i'$comment_to_hide]);
    } else {
        
ps_query("DELETE FROM comment WHERE ref = ?", array("i",$comment_to_hide));
    }
    if (!
is_null($root)) {
        
clean_comment_tree($root);
    }

    return 
true;
}

This article was last updated 3rd March 2026 18:05 Europe/London time based on the source file dated 3rd March 2026 15:10 Europe/London time.