在codex中的示例中,现在需要参数数组。
global $post, $current_user; //for this example only :)
$commentdata = array(\'comment_post_ID\' => $post->ID, // to which post the comment will show up
\'comment_author\' => \'Another Someone\', //fixed value - can be dynamic
\'comment_author_email\' => \'[email protected]\', //fixed value - can be dynamic
\'comment_author_url\' => \'http://example.com\', //fixed value - can be dynamic
\'comment_content\' => \'Comment messsage...\', //fixed value - can be dynamic
\'comment_type\' => \'\', //empty for regular comments, \'pingback\' for pingbacks, \'trackback\' for trackbacks
\'comment_parent\' => 0, //0 if it\'s not a reply to another comment; if it\'s a reply, mention the parent comment ID here
\'user_id\' => $current_user->ID, //passing current user ID or any predefined as per the demand
);
//Insert new comment and get the comment ID
$comment_id = wp_new_comment( $commentdata );
您可以查看wp_filter_comment(),源代码显示了一些设置fill$commentdata的过滤器。可能您使用的插件使用了其中一个。