WordPress doesn't send a notification email when submitting a comment using REST API

wordpress.stackexchange https://wordpress.stackexchange.com/questions/387934

  •  20-05-2021
  •  | 
  •  

Domanda

When I submit a comment on the WordPress website, it sends me a notification email.
but when I submit a comment through REST API, WordPress doesn't send me a notification email.
What should I do to make WordPress send a notification email when I submit a comment with REST API?

È stato utile?

Soluzione

Here's an untested suggestion for the REST API case:

add_action( 'rest_after_insert_comment', 'wp_new_comment_notify_moderator' );

emulating the existing:

add_action( 'comment_post', 'wp_new_comment_notify_moderator' );

Note the different callback inputs between actions and that we use that get_comment() should handle both comment ID or comment object as an input.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top