Function Reference/update comment meta
Description
The function update_comment_meta() updates the value of an existing comment meta key for the specified comment.
This may be used in place of the add_comment_meta() function. The first thing this function will do is make sure that $meta_key already exists on $comment_id. If it does not it will be added.
Returns true on success and false on failure.
Usage
<?php update_comment_meta( $comment_id, $meta_key, $meta_value, $prev_value ); ?>
Parameters
- $comment_id
- (integer) (required) The ID of the comment which contains the field you will edit.
- Default: None
- $meta_key
- (string) (required) The key of the custom field you will edit.
- Default: None
- $meta_value
- (mixed) (required) The new value of the custom field. A passed array will be serialized into a string.
- Default: None
- $prev_value
- (mixed) (optional) The old value of the custom field you wish to change. This is to differentiate between several fields with the same key. If omitted, and there are multiple rows for this post and meta key, all meta values will be updated.
- Default: None
Examples
Default Usage
<?php update_comment_meta( 3416, 'my_key', 'Brad' ); ?>
Related
Template:Comment Meta Tags