function send_comment_reply_email_async( $comment_id ) {
wp_schedule_single_event( time(), 'send_comment_reply_email', array( $comment_id ) );
}
add_action( 'send_comment_reply_email', 'async_send_comment_reply_email_handler' );
function async_send_comment_reply_email_handler( $comment_id ) {
send_comment_reply_email( $comment_id );
}
add_action( 'wp_insert_comment', 'send_comment_reply_email_async', 10, 1 );
function send_comment_reply_email($comment_id) {
$comment = get_comment($comment_id);
$parent_comment = get_comment($comment->comment_parent);
$parent_comment_author_email = $parent_comment->comment_author_email;
if (empty($parent_comment) || $comment->comment_author_email === $parent_comment_author_email) {
return;
}
$blog_name = get_bloginfo('name');
$blog_url = get_bloginfo('url');
$blog_des = get_bloginfo('description');
$to = $parent_comment_author_email;
$subject="reply";
$headers[] = 'Content-Type: text/html; ' . get_option('blog_charset');
$headers[] = 'From: ' . $blog_name;
$comment_date = date("Y-m-d H:i:s", strtotime($comment->comment_date));
$parent_comment_date = date("Y-m-d H:i:s", strtotime($parent_comment->comment_date));
$message="";
wp_mail($to, $subject, $message, $headers);
}
Este es un fragmento de código incrustado en el tema. Antes no había ningún problema, pero en la última versión, los correos electrónicos del sistema se pueden enviar con normalidad, pero este fragmento de código que configuré por separado no tiene efecto. Por favor, ayúdenme a encontrar dónde está el problema, gracias.