Make WordPress Core

Opened 10 years ago

Closed 16 months ago

Last modified 16 months ago

#40352 closed defect (bug) (wontfix)

WP REST API, Comments Not Triggering 'comment_post'

Reported by: stickypixel Owned by:
Priority: normal Milestone:
Component: Comments Version: 4.7
Severity: normal Keywords: dev-feedback
Cc: Focuses: rest-api

Description

Hello,

I’ve noticed that when comments are created using the WP API that notification emails are not sent out to the author of the post or moderators. (When testing, If I add the comment via the admin interface, it works as expected).

On debugging, I noticed that the filter ‘comment_post’ is not being called when inserted via the API. For now, I used the following workaround:

function mytheme_comment_inserted($comment_id, $comment_object) {
  wp_notify_postauthor( $comment_id );
}
add_action('wp_insert_comment','mytheme_comment_inserted');

I already posted on the support forum here: ​https://wordpress.org/support/topic/wp-api-comments-not-sending-notifications/#post-8987973 and it was suggested this could be intentional behaviour but that this also could, in fact, be reported as a bug?

Thanks!

Chris

Change History (5)

#1 @swissspidy
10 years ago

  • Version 4.7.3 → 4.7

#2 @johnbillion
10 years ago

  • Component REST API → Comments
  • Keywords dev-feedback added

Thanks for the ticket @stickypixel.

This is caused by the comment controller calling wp_insert_comment() directly, instead of calling wp_new_comment(), which is the function that triggers the comment_post action and is used throughout the rest of the admin area.

This might be an intentional design decision by the REST API team.

This ticket was mentioned in ​Slack in #core-restapi by andraganescu. ​View the logs.


7 years ago

#4 @callumbw95
16 months ago

  • Resolution → wontfix
  • Status new → closed

Hi All,
I have done a bit of digging into this, and I came across this ​GitHub Issue that revolved around the same issue. Looking at the last comment, it appears that this was an intentional decision, as wp_new_comment() does a lot of unwanted functionality in the instance of the REST API. As of such this functionality is unlikely to change, and I am going to mark this is wontfix. However if you have anything else to add to the discussion please reopen the ticket. 😃

#5 @peterwilsoncc
16 months ago

  • Milestone Awaiting Review
Note: See TracTickets for help on using tickets.