I'm looking to send out emails to subscribers when a comment has been approved.

The two actions in the Codex are:


add_action('comment_post', 'callback', $priority, $accepted_args);

Where the arguments are comment_ID and approval status (0 or 1).


add_action('edit_comment', 'callback', $priority, $accepted_args);

With argument comment_ID

By default comments are not approved when they are posted so I think I would be editing them when I approve them but it's unclear in the Codex. Which option should I use when I approve a comment?

1 Answer 1


Just like posts, a comment can have an array of different statuses, so instead of naming a hook with each status, they have transition hooks, which tell you what status it had before and what's the new status. In your case, this might do the trick:

add_action('transition_comment_status', 'my_approve_comment_callback', 10, 3);
function my_approve_comment_callback($new_status, $old_status, $comment) {
    if($old_status != $new_status) {
        if($new_status == 'approved') {
            // Your code here

Let us know how it goes?

  • Wouldn't the tag be comment_(old status)_to_(new status), also found in the Codex?
    – AlxVallejo
    Jul 27, 2012 at 14:30
  • 2
    Could be, too, but it implies that you know the old status. You could approve a comment marked as spam, or approve an unapproved comment, so you'd have to use two hooks in order to trigger your function. I'd say go with the transition, because it makes your code easier to maintain. Jul 27, 2012 at 14:52
  • tested with a simple wp_mail(); function, but didin't get the test message. it is working for you? I use wp 3.5.1
    – Attila
    Apr 4, 2013 at 7:13
  • @user9909 just tested it running 3.5.1 and it works. Start with simpler code (error_log() in my case) and debug from there, perhaps? Using wp_mail() means additional places where things can go wrong, including many which have nothing to do with WP. Apr 4, 2013 at 11:21
  • 1
    Utilize the wp_insert_comment hook to catch comments that automatically approved on the fly. Mar 10, 2014 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.