web-dev-qa-db-fra.com

Erreur lors de l'envoi du commentaire

J'essaie d'appliquer ce tutoriel à mon blog. J'utilise le thème Bueno de Woothemes .

J'ajoute ce code au fichier functions.php de mon thème:

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

De plus, ce code a été ajouté au fichier comments.php du thème (sous </form>):

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

Mais quand j'essaye d'envoyer un commentaire, je reçois cette erreur:

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
Eray

Les deux derniers points doivent spécifier 2 arguments acceptés et non 1;

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