Basically I need to remove or comment our lines 1114 - 1116 in pluggable.php, and edit line 1113

These are the lines

$notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
$notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n";
$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";
$notify_message .= sprintf( __('URL    : %s'), $comment->comment_author_url ) . "\r\n";

They are all part of function - wp_notify_postauthor

I can replace the whole thing by creating a plugin (which is what I've done) - but is there a way to just change those affected lines - without replacing the whole function?



There is a hook that should let you alter that data-- comment_notification_text.

  function($notify_message,$comment_id) {

You could parse that $notify_message string and remove the parts you don't want.

  function($notify_message) {
    $notify_message = explode("\n",$notify_message);
    foreach ($notify_message as $k => $line) {
      $header = trim(substr($line,0,strpos($line,':')));
      switch ($header) {
        case 'E-mail':
        case 'URL' :
        case 'Whois':
        case 'Author' :
          $pat = '([^(]+)\(.*$';
          $notify_message[$k] = trim(preg_replace('|'.$pat.'|','$1',$line));
    $notify_message = implode("\n",$notify_message);
    return $notify_message;

I think that accomplishes what you were going for.

  • Wow - this looks good... I guess I'd dump this in my functions php? – JorgeLuisBorges Feb 25 '14 at 18:09
  • I should also clarify that I'm trying to remove any reference to the comment authors email or ip address - so for the author line its just the second two values I'm trying to drop (ip address and domain) – JorgeLuisBorges Feb 25 '14 at 18:10
  • That should work from functions.php, a plugin, or a mu-plugin file. – s_ha_dum Feb 25 '14 at 18:12
  • It won't work with translation though. You will need to work that out yourself. – s_ha_dum Feb 25 '14 at 18:12
  • If you still see email address, change 'E-mail' to 'Email' - seems like the notification string has changed. (I'm on WP 4.7.) – Brent Ozar Jan 21 '17 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.