add_comment_meta() WordPress Function

The add_comment_meta() function allows you to add arbitrary data to a comment record. This is useful if you want to store additional data for your own purposes. The first parameter is the comment ID, and the second parameter is the key for the data you're storing. The third parameter is the actual data you're storing. The fourth parameter is a boolean value that determines whether the data should be replaced if it already exists.

add_comment_meta( int $comment_id, string $meta_key, mixed $meta_value, bool $unique = 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 value: false


Top ↑

Return

(int|false) Meta ID on success, false on failure.


Top ↑

Source

File: wp-includes/comment.php

function add_comment_meta( $comment_id, $meta_key, $meta_value, $unique = false ) {
	return add_metadata( 'comment', $comment_id, $meta_key, $meta_value, $unique );
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More