2016-05-27 11 views
0

Welchen Code soll ich verwenden, um den Betreff von Benachrichtigungs-E-Mails in einem WordPress-Blog anzupassen?WordPress: Betreff in neuen Kommentarbenachrichtigungs-E-Mails anpassen

Ich meine die E-Mails, die an Autoren gesendet werden, wenn ein Kommentar von jemandem auf seinem Post hinterlassen wurde.

Im Moment ist das Thema über:

[% site-Titel%] Kommentar: "% post-title%"

Ich mag würde zu verwenden:

Neuer Kommentar wartet auf dich

Aktuellen Code in 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); 

Antwort

0

Sie haben die comment_moderation_subject Filter verwenden:

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

Frage @PierreLebedel aktualisiert wurde – baluba89

+0

Die Antwort bleibt unverändert; Sie müssen diesen Code hinzufügen, zusätzlich zu dem, was Sie bereits in functions.php haben – Pierre

+0

Fertig, aber ich bekomme immer noch das Standardthema. – baluba89

0

sieht aus wie Sie Filter verwenden muss.

Code unten in functions.php Put

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"; 
} 

untenstehenden Link verweisen - https://developer.wordpress.org/reference/hooks/comment_moderation_subject/

+0

Frage wurde @ManthanDave aktualisiert – baluba89