comments – comment_approved custom value

Question

I want to modify comments with an additional ‘comment_approved’ value. This value will be used elsewhere in a plugin that uses wp_list_comments.

Looking at the wp_set_comment_status function, I see this code (at about line 2371 in comment.php):

function wp_set_comment_status( $comment_id, $comment_status, $wp_error = false ) {
    global $wpdb;

    switch ( $comment_status ) {
        case 'hold':
        case '0':
            $status="0";
            break;
        case 'approve':
        case '1':
            $status="1";
            add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' );
            break;
        case 'spam':
            $status="spam";
            break;
        case 'trash':
            $status="trash";
            break;
        default:
            return false;
    }

I don’t see a filter I can use to allow for another value (say “nodisplay” or “42”) that will allow wp_set_comment_status to store my custom value.

Is there a way to store a custom value in the comment_approved field of the comments table?

The intent is to allow a plugin ajax call to set a comment to a status of ’42’ or ‘nodisplay’. The plugin will also look for that value and remove that comment from the wp_list_comments process. (So a filter is also needed to intercept the output of wp_list_comments to remove that ’42’ comment from the displayed list.)

I note this question has a similar intent, but it is from 2013, so perhaps there is a way now in 2022?

0
Rick Hellewell 5 days 2022-09-19T17:42:26-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse