You are here:  » Email notification for pending reviews


Email notification for pending reviews

Submitted by paul30 on Sat, 2008-10-18 06:47 in

Hello, just thought it could be useful for someone, this is a very simple [and that means stable :)] mod for site administrators who want to be notified on the reviews as soon as user will post it.
What it does, is it sends you an email saying that a review has been posted and now it is awaiting your approval.

To apply the above functionality open your reviews.php and around line 16 find:

database_queryModify($sql,$insertId);
    }
    if ($config_useRewrite)
    {
      header("Location: ".$_SERVER["REQUEST_URI"]."?pending=1");
    }
    else
    {
      header("Location: ".$_SERVER["REQUEST_URI"]."&pending=1");
    }

Roght after that add:

//SEND EMAIL NOTIFICATION
$to = 'test@example.com';
$subject = 'Review is Pending For Approval';
$from = 'test@example.com';
$message = 'A rating or review has just been submitted and needs to be approved to go live, please login to http://www.YOUR-SITE-URL.com/admin/moderate.php to review it.';
mail($to, $subject, $message, "From: $from");

Edit the $to, $subject, $from, $message as you wish...

Thats it! - Hope someone will find it useful..

Cheers
Pasha

Submitted by atman on Thu, 2009-04-02 05:51

paul30, thanks for the free mod! i am using it on my new sites.

david, can i set PT to include the actual review on the email message using the MOD above?

Also, is it also possible to auto approve reviews?

Submitted by support on Thu, 2009-04-02 07:30

Sure - at the point where the email is created the review body is in the $_POST["comments"] variable, and the product name is in $q, so instead of:

$message = 'A rating or review has just been submitted and needs to be approved to go live, please login to http://www.YOUR-SITE-URL.com/admin/moderate.php to review it.';

...you could use:

$message = $q."\n\n".$_POST["comments"];

To auto-approve reviews, firstly, look for the following code on line 14 of reviews.php

$sql = "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='0',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."'";

...and REPLACE this with:

$sql = "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='1',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."'";

...and then on the next line, look for the following code:

database_queryModify($sql,$insertId);

...and REPLACE this with:

database_queryModify($sql,$insertId);
require("includes/admin.php");
admin_importReviews();

Cheers,
David.

Submitted by atman on Fri, 2009-04-03 18:56

nice! nice! :)

and lastly, can i insert the actual URL of the product page? This can be useful if you have multiple PT store domains.

Submitted by support on Sat, 2009-04-04 08:25

Hi,

Try replacing:

$message = $q."\n\n".$_POST["comments"];

...with:

$message = $q."\n\n".$_POST["comments"]."\n\nhttp://".$_SERVER["HTTP_HOST"].str_replace("review","product",$_SERVER["REQUEST_URI"]);

Cheers,
David.

Submitted by Perce2 on Fri, 2017-07-14 13:02

Is there an update to this now days as this doesn't seem to work anymore on all my sites, including Wordpress installs.

Thanks in advance.
G.

Submitted by support on Mon, 2017-07-17 07:24

Hi,

The first thing to check if email is not working is whether your server is configured to be able to send email as this not always the case so you may need to ask your host to provide email support for PHP however you can make a test script easily, just create the following file called something like emailtest.php and upload to your site and browse to the script;

<?php
  mail
("you@example.com","Email Test","Testing 1234");
?>

Cheers,
David.
--
PriceTapestry.com

Submitted by Perce2 on Thu, 2017-07-27 16:21

Hi David, thanks for the test script.

Yes, I can confirm my sites can send out php mail, but if I fill out a test review I don't receive anything.

Submitted by support on Fri, 2017-07-28 06:50

Hi,

I know you're running the latest distribution and I think the plugin so to re-document for a both just in case, for a basic email but including the host name which will be handy for multiple instllations; for standalone Price Tapestry, edit reviews.php and look for the following code at line 16:

      database_queryModify($sql,$insertId);

...and REPLACE with:

      database_queryModify($sql,$insertId);
      mail("you@example.com","Review Pending","Review Pending at ".$_SERVER["HTTP_HOST"]);

And for the plugin (PriceTapestry.org for WordPress version 3) edit the plugin file pto/pto.php and look for the following code at line 514:

      $wpdb->query($sql);

...and REPLACE with:

      $wpdb->query($sql);
      mail("you@example.com","Review Pending","Review Pending at ".$_SERVER["HTTP_HOST"]);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com