Hi – thanks for the response. So for a given review I understand there would only ever be one assigned post (certainly I cant see a scenario in my case where there would be more). I’ve tried using the above code snippet to retrieve the URL of the post the review was added to, however no joy! Code below, any ideas please? Cheers M.
/**
* Send an email notification to the review author after responding to a review
* This snippet assumes that your review form includes the email field
* Paste this code in your theme’s functions.php file.
* @param \GeminiLabs\SiteReviews\Review $review
* @param string $response
* @return void
*/
add_action(‘site-reviews/review/responded’, function ($review, $response) {
$hasResponse = !empty($review->response(1));
$hasResponseUserId = !empty(get_post_meta($review->ID, ‘_response_by’, true));
if (empty($response) || $hasResponse || $hasResponseUserId) {
return; // only send an email if the response is not empty and there is no previous response
}
$posturl = $review->assigned_posts();
$wbpermalink = ‘<html><Head></Head><Body>Letting you know we have posted a reply to your review at</html>’;//MG
$email = glsr(‘Modules\Email’)->compose([
‘to’ => $review->email,
‘subject’ => ‘[My Website] We have responded to your review!’,
//’message’ => $response,
‘message’ => $wbpermalink,
‘headers’ => ‘Content-Type: text/html; charset=”UTF-8″‘, //MG
]);
$email->send();
}, 10, 2);`