On this page
wp_get_comment_status( int|WP_Comment $comment_id ): string|false
Retrieves the status of a comment by comment ID.
Parameters
$comment_idint|WP_Comment Required-
Comment ID or WP_Comment object
Return
string|false Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
Source
File: wp-includes/comment.php. View all references
function wp_get_comment_status( $comment_id ) {
$comment = get_comment( $comment_id );
if ( ! $comment ) {
return false;
}
$approved = $comment->comment_approved;
if ( null == $approved ) {
return false;
} elseif ( '1' == $approved ) {
return 'approved';
} elseif ( '0' == $approved ) {
return 'unapproved';
} elseif ( 'spam' === $approved ) {
return 'spam';
} elseif ( 'trash' === $approved ) {
return 'trash';
} else {
return false;
}
}
Related
Uses
| Uses | Description |
|---|---|
| get_comment() wp-includes/comment.php | Retrieves comment data given a comment ID or comment object. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Comments_Controller::handle_status_param() wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php | Sets the comment_status of a given comment object when creating or updating a comment. |
| WP_Comments_List_Table::handle_row_actions() wp-admin/includes/class-wp-comments-list-table.php | Generates and displays row actions links. |
| _wp_dashboard_recent_comments_row() wp-admin/includes/dashboard.php | Outputs a row for the Recent Comments widget. |
| wp_ajax_delete_comment() wp-admin/includes/ajax-actions.php | Ajax handler for deleting a comment. |
| wp_ajax_dim_comment() wp-admin/includes/ajax-actions.php | Ajax handler to dim a comment. |
| WP_Comments_List_Table::column_date() wp-admin/includes/class-wp-comments-list-table.php | |
| WP_Comments_List_Table::single_row() wp-admin/includes/class-wp-comments-list-table.php | |
| wp_new_comment() wp-includes/comment.php | Adds a new comment to the database. |
| wp_delete_comment() wp-includes/comment.php | Trashes or deletes a comment. |
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_comment_status