#16995 closed defect (bug) (duplicate)
wp_notify_postauthor() pluggable behavior problem
Reported by: | dglingren | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Keywords: | has-patch | |
Focuses: | Cc: |
Description (last modified by )
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)
Change History (10)
#1
@
14 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
#3
@
14 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.
#4
@
14 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
@
14 years ago
@solarissmoke: Coding standards:
Instead of:
if(
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);
It's not a good idea to lump two issues in the same ticket.
Please open a new ticket for the first issue.