Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/update comment meta


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.


 <?php update_comment_meta$comment_id$meta_key$meta_value$prev_value ); ?> 


(integer) (required) The ID of the comment which contains the field you will edit.
Default: None
(string) (required) The key of the custom field you will edit.
Default: None
(mixed) (required) The new value of the custom field. A passed array will be serialized into a string.
Default: None
(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

Return Values

False on failure, true if success.


Default Usage

<?php update_comment_meta( 3416, 'my_key', 'Brad' ); ?>


Change Log

Since: 2.9.0

Source File

update_comment_meta() is located in wp-includes/comment.php


Comment Meta Functions: add_comment_meta(), get_comment_meta(), update_comment_meta(), delete_comment_meta()

See also index of Function Reference and index of Template Tags.