WordPress.org

Codex

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

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.

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

Return Values

(boolean) 
False on failure, true if success.

Examples

Default Usage

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

Notes

Change Log

Since: 2.9.0

Source File

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

Related

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.