Error While Sending Comment

时间:2011-03-12 作者:Eray

我正在申请this tutorial 到我的博客。我正在使用Woothemes\'Bueno Theme .

我正在将此代码添加到主题的函数中。php文件:

function ymc_add_meta_settings($comment_id) {
  add_comment_meta(
    $comment_id, 
    \'mailchimp_subscribe\', 
    $_POST[\'mailchimp_subscribe\'], 
    true
  );
}
add_action(\'comment_post\', \'ymc_add_meta_settings\', 1);

function ymc_subscription_add( $cid, $comment ) {
  $cid = (int) $cid;

  if ( !is_object($comment) )
    $comment = get_comment($cid);

  if ( $comment->comment_karma == 0 ) {
   $subscribe = get_comment_meta($cid, \'mailchimp_subscribe\', true);
if ( $subscribe == \'on\' ) {
update_comment_meta($cid, \'mailchimp_subscribe\', \'off\');

/////////////////////////////////////
///////MailChimp////////////////////
///////////////////////////////////
  $apikey   = \'MYAPIKEY-us2\';
$listid   =  \'MYLISTID\';
$endpoint   = \'http://us2.api.mailchimp.com/1.3/?output=php\';

$request   = array(
  \'apikey\' => $apikey,
  \'id\' => $listid,
  \'email_address\' => strtolower( $comment->comment_author_email ),
  \'double_optin\' => true,
  \'merge_vars\' => array(
    \' <merge tag for name> \' => $comment->comment_author,
    \'OPTIN_IP\' => $comment->comment_author_IP,
  )
);
$result = wp_remote_post(
  $endpoint.\'&method=listSubscribe\', 
  array( \'body\' => json_encode($request) ) 
);
/////////////////////////////////////
///////MailChimp  Ended////////////////////
///////////////////////////////////



}
  }
}
add_action(\'comment_approved_\',\'ymc_subscription_add\',10,1);
add_action(\'comment_post\', \'ymc_subscription_add\', 60,1);
此外,此代码还添加到注释中。php主题文件(如下</form>) :

<input style="width: auto;" type="checkbox" name="mailchimp_subscribe"   id="mailchimp_subscribe"/>
<label for="mailchimp_subscribe">
Subscribe
</label>
</p>
但当我试图发送评论时,我遇到了以下错误:

Warning: Missing argument 2 for ymc_subscription_add() in /home/content/blabla/themes/bueno/functions.php on line 36

Warning: Cannot modify header information - headers already sent by (output started at /home/content/blabla/themes/bueno/functions.php:36) in /home/blabla/html/wp-comments-post.php on line 95

Warning: Cannot modify header information - headers already sent by (output started at /home/blabla/html/wp-content/themes/bueno/functions.php:36) in /home/content/blabla/wp-comments-post.php on line 96

Warning: Cannot modify header information - headers already sent by (output started at /home/blabla/html/wp-content/themes/bueno/functions.php:36) in /home/content/blabla/wp-comments-post.php on line 97

Warning: Cannot modify header information - headers already sent by (output started at /home/contentblabla/html/wp-content/themes/bueno/functions.php:36) in /home/content/blabla/wp-includes/pluggable.php on line 897

1 个回复
最合适的回答,由SO网友:TheDeadMedic 整理而成

最后两个挂钩应指定2 接受的参数,不是1;

add_action(\'comment_approved_\',\'ymc_subscription_add\', 10, 2);
add_action(\'comment_post\', \'ymc_subscription_add\', 60, 2);

结束

相关推荐

由于自定义Comments.php文件,无法连接评论

嘿,我试着使用wordpress的线程评论功能,但由于自定义主题,所以没有成功。我尝试了wp线程评论插件,它的工作方式很有魅力,但不幸的是,它与FV社区新闻插件有冲突,它在社区新闻区域/小部件上显示了一个回复按钮。所以我试着手动操作。。。没有运气。谁能给我提个建议或者告诉我什么地方我可以得到一些数据来解决这个问题吗。我的wordpress版本是3.0.4cheers当前注释。php<?php // Do not delete these lines if (!empty($_SERV