WordPress doesn't send a notification email when submitting a comment using REST API
-
20-05-2021 - |
سؤال
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?
المحلول
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.
لا تنتمي إلى wordpress.stackexchange