Send mail to the user when comment gets approved in wordpress

Unknown | 8:38 AM

Send mail to the user when comment gets approved in wordpress

Action hook after comment approval




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

$user_id= $comment->user_id;
$notification_meta_for_user = get_user_meta( $user_id,'email_notification',true );

wp_mail($comment->comment_author_email,'New comment on your article "'. stripslashes($postdata->post_title),stripslashes($comment->comment_content));
   
}
}

add_action('wp_set_comment_status', 'notify_approval_to_contributor',10,1);
add_action('edit_comment', 'notify_approval_to_contributor',10,1);

No comments:

Post a Comment

Avinash Kumar Singh © 2013. All Rights Reserved | Powered by-Blogger