Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notify email when someone's posted a review in WooCommerce

I noticed that Woocommerce's reviews are managed through Wordpress Comments. But why is it that Wordpress isn't notifying my email when someone posted a review to a product. I have set the "Email me whenever anyone posted a comment".

Is this function available in Woocommerce or i'm missing something?

Please advise, thanks everyone!

Regards, Ven

like image 845
Ven Francis Avatar asked Jun 17 '15 09:06

Ven Francis


1 Answers

By default Wordpress sends a notification to the author of the product/post (the person who created the product in your instance). The suggested site owner (settings > general) is not the recipient of these notifications. This is where the trouble might start. This author information is in Woocommerce hidden and is hard to figure out who that is in your user database. It might be that the original author of the product doesn't exist anymore, and especially if the original author has been deleted from the database and you didn't move the contents of that user to a new user.

The default comment notifications are produced in this Wordpress file: wp-includes/pluggable.php

Below is a trick to override the recipient for the comment/review notification, put this code in your child-theme's functions.php and change the part [email protected] to your desired email recipient and you will receive a notification every time someone adds a comment/review to your site.

function new_comment_moderation_recipients( $emails, $comment_id ) { 
    return array( '[email protected]' );
}
add_filter( 'comment_moderation_recipients', 'new_comment_moderation_recipients', 24, 2 );
add_filter( 'comment_notification_recipients', 'new_comment_moderation_recipients', 24, 2 );

I tested it and it works.

like image 71
Demian Avatar answered Sep 29 '22 12:09

Demian