1

I'm trying to apply this tutorial to my blog. I'm using Woothemes' Bueno Theme .

I'm adding this code to my theme's functions.php file :

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);

Also this code added to comments.php file of theme (below </form>) :

<input style="width: auto;" type="checkbox" name="mailchimp_subscribe"   id="mailchimp_subscribe"/>
<label for="mailchimp_subscribe">
Subscribe
</label>
</p>

But when i trying to send a comment, i'm getting this error :

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

The last two hooks should specify 2 accepted arguments, not 1;

add_action('comment_approved_','ymc_subscription_add', 10, 2);
add_action('comment_post', 'ymc_subscription_add', 60, 2);
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.