
And if you want to change the subject line, you can do this:
add_filter('site-reviews/notification/title', function ($title, $review) {
// change the notification $title (subject line) here
return $title;
}, 10, 2);
Thread Starter
Zee
(@laserjobs)
I should clarify, is is possible to put the “Assigned Post” in the Notification Email?
1. The site-reviews/notification/title hook provides access to the $review object, so you can get an array of the assigned_posts Post IDs (this is an array because Site Reviews version 5 allows you to assign reviews to multiple pages) and get the assigned post titles from that:
$postTitles = [];
foreach ($review->assigned_posts as $postId) {
$postTitles[] = get_the_title($postId);
}
And them implode the array of post title results and use them in the subject line.
2. If you want to do this in the email message, you can use the site-reviews/email/compose hook to modify the email data values. Simply add a custom template key to $data['template-tags'] and use that in the notification template:
/**
* @param array $data
* @param \GeminiLabs\SiteReviews\Modules\Email $email
* @return array
*/
add_filter('site-reviews/email/compose', function ($data, $email) {
$review = $email->data['review'];
$postTitles = [];
foreach ($review->assigned_posts as $postId) {
$postTitles[] = get_the_title($postId);
}
$data['template-tags']['assigned_posts'] = implode(', ', $postTitles);
return $data;
}, 10, 2);
Now you have a new template tag that you can use in the notification template:
{assigned_posts}
-
This reply was modified 5 years, 7 months ago by
Gemini Labs.
FYI: this will be added in v5.2.0
