Make WordPress Core

Opened 13 years ago

Closed 10 years ago

Last modified 10 years ago

#16995 closed defect (bug) (duplicate)

wp_notify_postauthor() pluggable behavior problem

Reported by: dglingren's profile dglingren Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Mail Keywords: has-patch
Focuses: Cc:

Description (last modified by scribu)

In my application a notification must be issued even when an author comments on their own post; this is not allowed by the default WordPress implementation. Lines 1015 - 1025 in function wp_notify_postauthor reject the author's comments and moderations.
Since wp_notify_postauthor is a pluggable function, I can change this behavior by implementing my own function and replacing the default.

However, there is also a redundant test of post authorship in wp-includes/comment.php, function wp_new_comment, around lines 1344 - 1348. This means that my custom wp_notify_postauthor is never called. My specific problem can be solved by commenting out a line of code:

// $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment

A real fix for this problem should move all of the user_id validation rules out of wp_new_comment and put them in wp_notify_postauthor where they can be modified as needed.

Attachments (2)

16995.diff (1.9 KB) - added by solarissmoke 13 years ago.
16995.2.diff (5.7 KB) - added by solarissmoke 13 years ago.
All nicely spaced :)

Download all attachments as: .zip

Change History (10)

#1 @scribu
13 years ago

  • Description modified (diff)
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Summary changed from wp_notify_postauthor From: problem and pluggable behavior problem to wp_notify_postauthor() pluggable behavior problem

It's not a good idea to lump two issues in the same ticket.

Please open a new ticket for the first issue.

#2 @scribu
13 years ago

  • Version 3.1 deleted

#3 @solarissmoke
13 years ago

  • Keywords has-patch added; needs-patch removed

Patch makes behaviour consistent with wp_notify_moderator(), where the notify option is checked inside the function. This allows complete override by a custom function.

13 years ago

#4 @dglingren
13 years ago

Thanks for the quick action. I have applied this patch to my install and it seems to work fine.

I have opened Ticket #17001 for the "From:" issue; thanks for your guidance.

#5 @scribu
13 years ago

@solarissmoke: Coding standards:

Instead of:


it should be:

if (

Easier to prevent than to cure. ;-)

While you're at it, you can also add spacing to these lines:

$comment = get_comment($comment_id); 
wp_notify_postauthor($comment_id, $comment->comment_type);

13 years ago

All nicely spaced :)

#6 @solarissmoke
13 years ago

@scribu: done, and added a few spaces elsewhere while I was at it

#7 @chriscct7
10 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #25699.

#8 @DrewAPicture
10 years ago

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.