• Just wondering the best way (Plugin? I’ve looked, or code location to start poking around) to trigger an email to the comment contributer when a comment has been approved by the moderator. It is for a wordpress blog that allows anyone to comment (No registration).

    Any ideas to get me started looking in the right direction?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter mogmismo

    (@mogmismo)

    Ok, I spent all morning making a manual patch to comment.php in wp-admin to send out an email, but it would never fire. Found out the case “approvecomment” in there never fires, but the dim-content case in admin-ajax does. That took way too long!

    So, I added a @wp_mail() function in the correct part of dim-content and it works. ~BUT~ it’s dirty and not upgrade safe. What’s the correct way to add this functionality?

    Thanks again.

    Thread Starter mogmismo

    (@mogmismo)

    Just found the hook: pre_comment_approved I think that’s what I need, yes?

    Much of the mailing functions in 2.5.1 don’t work. Set up a brand new blog, never got mailed the admin password for my files. Approved comments don’t get notified. However, pingbacks do seem to happen.

    This is a case of an “upgrade” and degraded the product.

    Hey mogmismo, could you outline your solution in detail? I am looking to implement the same functionality.

    All comments go to moderation for me. I would like a notification sent to the author when their comment gets approved.

    I was trying to do this very thing on a blog, and it was driving me nuts. Here’s the code I used that finally worked:

    function notify_approval_to_contributor ($comment_id){
    	$comment = get_comment($comment_id);
    	if ($comment->comment_approved == 1) {
    		$postdata = get_post($comment->comment_post_ID);
    		$author = get_userdata($postdata->post_author);
    		mail(
    			$author->user_email,
    			'New comment on your article "'. stripslashes($postdata->post_title),
    			stripslashes($comment->comment_content)
    		);
    	}
    }
    
    add_action('wp_set_comment_status', 'notify_approval_to_contributor');
    add_action('edit_comment', 'notify_approval_to_contributor');

    Initially, it was only working when comments were approved by clicking the checkboxes to perform multiple updates and then clicking Approve. Clicking the individual Approve links to do it “Ajax-style” wasn’t working. This was because I was only using the wp_set_comment_status action. I needed to add in the action for edit_comment as well. Once I was handling both actions, it worked beautifully. I hope this helps.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Emailing contributer when comment is approved’ is closed to new replies.