• Resolved Zee

    (@laserjobs)


    Would it be possible to put the Post Title in the Notification Email?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    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?

    Plugin Author Gemini Labs

    (@geminilabs)

    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}

    Thread Starter Zee

    (@laserjobs)

    Thanks!!!

    Plugin Author Gemini Labs

    (@geminilabs)

    FYI: this will be added in v5.2.0

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Request: Post title in Notification Email’ is closed to new replies.