WordPress函数文档add_comment_meta()
给一个评论添加meta自定义附加信息 描述 Add meta data field to a comment….
给一个评论添加meta自定义附加信息
描述
Add meta data field to a comment.
用法
<?php add_comment_meta( $comment_id, $meta_key, $meta_value, $unique ); ?>
参数
$comment_id
(int) (必填) Comment ID.
默认值: None
$meta_key
(string) (必填) Metadata name.
默认值: None
$meta_value
(mixed) (必填) Metadata value.
默认值: None
$unique
(boolean) (可选) Optional, default is false. Whether the same key should not be added.
默认值: false
返回值
(bool)
False for failure. True for success.
示例
Add a custom posted value to every new comment
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
 | 
 /* ———————————- 
 * wordpress函数 kim收集 
 * ———————————- */ 
<?php 
function add_custom_comment_field( $comment_id ) {
 
   add_comment_meta( $comment_id, ‘my_custom_comment_field’, $_POST[‘my_custom_comment_field’] );
 
} 
add_action( ‘comment_post’, ‘add_custom_comment_field’ );
 
?> 
 | 
历史
添加于 版本: 2.9
源文件
add_comment_meta() 函数的代码位于 wp-includes/comment.php
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
 | 
 /* ———————————- 
 * wordpress函数 kim收集 
 * ———————————- */ 
/** 
 * Add meta data field to a comment. 
 * 
 * @since 2.9.0 
 * @link https://codex.wordpress.org/Function_Reference/add_comment_meta 
 * 
 * @param int $comment_id Comment ID. 
 * @param string $meta_key Metadata name. 
 * @param mixed $meta_value Metadata value. 
 * @param bool $unique Optional, default is false. Whether the same key should not be added. 
 * @return int|bool Meta ID on success, false on failure. 
 */ 
function add_comment_meta($comment_id, $meta_key, $meta_value, $unique = false) {
 
	return add_metadata(‘comment’, $comment_id, $meta_key, $meta_value, $unique);
 
} 
 | 
相关
Comment Meta Function(函数)s: add_comment_meta(), get_comment_meta(),
update_comment_meta(),
 delete_comment_meta()
- 原文:http://codex.wordpress.org/Function_Reference/add_comment_meta
 
类别:WordPress函数文档、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论功能已经关闭!