wake-up-neo.com

Anpassen des Betreffs in Kommentarbenachrichtigungs-E-Mails

Wie kann man den folgenden Code in functions.php anpassen, um "Neuer Kommentar" als Betreff in E-Mails mit Kommentarbenachrichtigungen anstelle des standardmäßigen WordPress-Betreffs zu verwenden?

function wpd_comment_notification_text( $notify_message, $comment_id ){
// get the current comment and post data
$comment = get_comment( $comment_id );
$post = get_post( $comment->comment_post_ID );
// don't modify trackbacks or pingbacks
if( '' == $comment->comment_type ){
    // build the new message text
    $notify_message  = sprintf( __( 'A new reviewer wants to receive "%s"' ), $post->post_title ) . "\r\n";
    $notify_message .= sprintf( __('Author : %1$s'), $comment->comment_author ) . "\r\n";
    $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
    $notify_message .= sprintf( __('When you are logged, you can see details about the reviewer reputation here: %s'), get_comment_link( $comment_id ) ) . "\r\n";

    if ( user_can( $post->post_author, 'edit_comment', $comment_id ) ) {
        if ( EMPTY_TRASH_DAYS )
            $notify_message .= sprintf( __(''), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n";
        else
            $notify_message .= sprintf( __(''), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n";
        $notify_message .= sprintf( __(''), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n";
    }
}
// return the notification text
return $notify_message;
}
add_filter( 'comment_notification_text', 'wpd_comment_notification_text', 20, 2 );
5
baluba89

Wenn ich Sie richtig verstehe, möchten Sie die Betreffzeile der E-Mail ändern. Der Hook Ihres Codes ändert nur den Inhalt der E-Mail. Es gibt einen anderen Haken für das Thema:

add_filter('comment_notification_subject', 'wpse_228315_comment_notification_subject');

function wpse_228315_comment_notification_subject($subject, $comment_id){
    return "New comment";
    }
2
cjbj