WordPress.org

Ready to get started?Download WordPress

Forums

Comment Notification LOOK/DESIGN / FORMAT (9 posts)

  1. vean
    Member
    Posted 5 years ago #

    Hy,

    I'm looking all over and can't find solution. Maybe I search with wrong term so please help me.

    I NEED to change what is sent to post author where there is new comment on post. (change comment notification look)
    Is there some plugin or do I need to change core/theme files?
    Where should I find that code? I was also looking over all files.

    I DO NOT need to change to who is email sent.

    Usually post author get:
    Post title
    Author + IP address
    E-Mail
    URL
    Whois
    Comments text...

    I don't need all that stuff, so I would need to remove some of them, and I will put some others.

    If this is answered somewhere else please point me there. I really can not find it.

    Thanks, very very much for any help.

  2. vean
    Member
    Posted 5 years ago #

    I'm sorry to post 2 same topics, but I get some error from bbpress.
    I ask moderators to delete 1 if is possible.

    Sorry once again.

  3. vean
    Member
    Posted 5 years ago #

    Anyone? Anything?

    Please...

  4. vean
    Member
    Posted 5 years ago #

    ?

  5. vean
    Member
    Posted 5 years ago #

    I really can not believe that there is no reply...........

    I read all the time that wordpress forum is worst from all, but never have that problem before.

    I really hope so I wouldn't agree with that thought... :)

  6. spiff06
    Member
    Posted 5 years ago #

    Sorry for resurrecting a two-month-old thread, but a user just cringed at the fact that there was too much information posted on notifications, and requested some things, such as IP address, should be taken out.

    The culprit is function wp_notify_postauthor(), in /wp-includes/pluggable.php. But it's also enclosed in a hook to check whether the function's been defined before, so it can be overridden in functions.php, like all other pluggable functions.

    I pasted the following in my theme's functions.php file:

    if ( ! function_exists('wp_notify_postauthor') ) :
    /**
     * Notify an author of a comment/trackback/pingback to one of their posts.
     *
     * @since 1.0.0
     *
     * @param int $comment_id Comment ID
     * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
     * @return bool False if user email does not exist. True on completion.
     */
    function wp_notify_postauthor($comment_id, $comment_type='') {
    	$comment = get_comment($comment_id);
    	$post    = get_post($comment->comment_post_ID);
    	$user    = get_userdata( $post->post_author );
    
    	if ('' == $user->user_email) return false; // If there's no email to send the comment to
    
    	$comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
    
    	$blogname = get_option('blogname');
    
    	if ( empty( $comment_type ) ) $comment_type = 'comment';
    
    	if ('comment' == $comment_type) {
    		$notify_message  = sprintf( __('New comment on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
    		$notify_message .= sprintf( __('Author : %1$s'), $comment->comment_author ) . "\r\n";
    		$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    		$notify_message .= __('You can see all comments on this post here: ') . "\r\n";
    		$subject = sprintf( __('[%1$s] Comment: "%2$s"'), $blogname, $post->post_title );
    	} elseif ('trackback' == $comment_type) {
    		$notify_message  = sprintf( __('New trackback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
    		$notify_message .= sprintf( __('Website: %1$s'), $comment->comment_author ) . "\r\n";
    		$notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
    		$notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n";
    		$subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title );
    	} elseif ('pingback' == $comment_type) {
    		$notify_message  = sprintf( __('New pingback on your post #%1$s "%2$s"'), $comment->comment_post_ID, $post->post_title ) . "\r\n";
    		$notify_message .= sprintf( __('Website: %1$s'), $comment->comment_author ) . "\r\n";
    		$notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n";
    		$notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n";
    		$subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title );
    	}
    	$notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n";
    	$notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n";
    	$notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n";
    
    	$wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME']));
    
    	if ( '' == $comment->comment_author ) {
    		$from = "From: \"$blogname\" <$wp_email>";
    		if ( '' != $comment->comment_author_email )
    			$reply_to = "Reply-To: $comment->comment_author_email";
    	} else {
    		$from = "From: \"$comment->comment_author\" <$wp_email>";
    		if ( '' != $comment->comment_author_email )
    			$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
    	}
    
    	$message_headers = "$from\n"
    		. "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    
    	if ( isset($reply_to) )
    		$message_headers .= $reply_to . "\n";
    
    	$notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
    	$subject = apply_filters('comment_notification_subject', $subject, $comment_id);
    	$message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
    
    	@wp_mail($user->user_email, $subject, $notify_message, $message_headers);
    
    	return true;
    }
    endif;

    It prunes the IP/WhoIS/email information from the email.
    Untested, but should work.
    Hope this helps.

  7. spiff06
    Member
    Posted 5 years ago #

    And oops, the above code should be placed inside a plugin file, placed in the plugins directory and activated in the administration area. So you have to enclose the above in the following:

    <?php
    /*
    Plugin Name: e-mail privacy
    Plugin URI: http://www.me.com/
    Description: Hides private details from comment notification emails, such as IP address and email.
    Author: Me
    Version: 1.0
    Author URI: http://www.me.com/
    */
    
    if ( ! function_exists('wp_notify_postauthor') ) :
    
    etc. etc. etc.
    
    endif;
    ?>
  8. aussiedude
    Member
    Posted 5 years ago #

    Thanks for the tip.
    I don't know why these things aren't configurable instead of requiriing a hack. I am sure many people don't want to see all that stuff in the notification emails.

    Thanks again!

  9. Zoinks! Graphics
    Member
    Posted 4 years ago #

    Any way to change the from address of notification emails from the default "wordpress@domainname.com"? Whoo mentioned in another post that there are several plugins to achieve that but after searching for hours I'm still no closer to a solution....

Topic Closed

This topic has been closed to new replies.

About this Topic