add_comment_meta( int $comment_id, string $meta_key, mixed $meta_value, bool $unique = false ): int|false
Adds meta data field to a comment.
Parameters
-
$comment_id
int Required -
Comment ID.
-
$meta_key
string Required -
Metadata name.
-
$meta_value
mixed Required -
Metadata value. Must be serializable if non-scalar.
-
$unique
bool Optional -
Whether the same key should not be added.
Default:
false
Return
int|false Meta ID on success, false on failure.
Source
File: wp-includes/comment.php
.
View all references
function add_comment_meta( $comment_id, $meta_key, $meta_value, $unique = false ) {
return add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique );
}
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Basic Example
Add a custom posted value to every new comment