WordPress: настройка темы в новых уведомлениях о комментариях

Какой код следует использовать, чтобы настроить тему уведомлений по электронной почте в блоге WordPress?

Я имею в виду электронные письма, отправленные авторам сообщений, когда кто-то оставил комментарий в своем сообщении.

На данный момент речь идет о:

[% site-title%] Комментарий: «% post-title%»

Я хотел бы использовать:

Новый комментарий ждет вас

Текущий код в functions.php

function comment_moderation_post_author_only($emails, $comment_id)
{
$comment = get_comment($comment_id);
$post = get_post($comment->comment_post_ID);
$user = get_userdata($post->post_author);

// Return only the post author if the author can modify.
if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) )
return array( $user->user_email );

return $emails;
}

add_filter('comment_moderation_recipients', 'comment_moderation_post_author_only', 11, 2);

0

Решение

Вы должны использовать comment_moderation_subject фильтр:

add_filter('comment_moderation_subject', 'my_comment_moderation_notification_subject');
function my_comment_moderation_notification_subject($subject, $comment_id){
return "New comment is waiting for you";
}
0

Другие решения

Похоже, вам нужно использовать фильтры.

Поместите ниже код в вашем functions.php

add_filter('comment_moderation_subject', 'temp_comment_moderation_notification_subject');
function temp_comment_moderation_notification_subject($subject, $comment_id){
return "New comment is waiting for you";
}

Пожалуйста, обратитесь по ссылке ниже —
https://developer.wordpress.org/reference/hooks/comment_moderation_subject/

0