Make WordPress Core

Opened 7 years ago

Last modified 5 years ago

#40352 new defect (bug)

WP REST API, Comments Not Triggering 'comment_post'

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



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 );

I already posted on the support forum here: and it was suggested this could be intentional behaviour but that this also could, in fact, be reported as a bug?



Change History (3)

#1 @swissspidy
7 years ago

  • Version changed from 4.7.3 to 4.7

#2 @johnbillion
7 years ago

  • Component changed from REST API to 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.

5 years ago

Note: See TracTickets for help on using tickets.