delete_comment_meta()
Deletes additional comment data (also what custom fields for posts).
Data can be deleted based on the key or on the key and value. Deleting based on key and value will allow separating different data with the same key, allowing to delete specifically indicated data.
delete_comment_meta() allows deleting any additional data associated with the comment that was set using add_comment_meta(). This is analogous to delete_post_meta().
Uses: delete_metadata()
No Hooks.
Returns
true|false. Boolean: false (on failed deletion) or true (if the field was successfully deleted).
Usage
delete_comment_meta( $comment_id, $meta_key, $meta_value );
- $comment_id(integer) (required)
- ID of the comment whose metadata will be deleted.
- $meta_key(string) (required)
- Key of the comment metadata to be deleted.
- $meta_value(string/array/integer/object/boolean)
- Value of the comment metadata to be deleted.
Default: ''
Examples
#1 Delete all comment metadata with the key my_meta_key
delete_comment_meta( 5, 'my_meta_key' );
#2 Delete comment metadata with my_meta_key and foo value
delete_comment_meta( 5, 'my_meta_key', 'foo' );
Changelog
| Since 2.9.0 | Introduced. |
delete_comment_meta() delete comment meta code WP 6.8.3
function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
return delete_metadata( 'comment', $comment_id, $meta_key, $meta_value );
}