• Resolved Theo Pape

    (@theo38)


    Hi there,

    Could you please add another option to notifications. At the moment you have ‘Send to author of the page that the review is assigned to’, but could you please add another option to ‘Send notification to assigned_users‘ (or ‘Send to users that the review is assigned to’? Or let me know how I can hook into this?

    Thanks,
    Theo

    • This topic was modified 2 years, 11 months ago by Theo Pape.
    • This topic was modified 2 years, 11 months ago by Theo Pape.
Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Thread Starter Theo Pape

    (@theo38)

    Thanks Paul.

    Thread Starter Theo Pape

    (@theo38)

    Another minor suggestion: could you please add BCC – so that we can define both the email ‘to’ and ‘bcc’? For instance, I would like to send the review to the assigned user and the admin email, but ideally the latter as BCC…

    • This reply was modified 2 years, 11 months ago by Theo Pape.
    • This reply was modified 2 years, 11 months ago by Theo Pape.
    Thread Starter Theo Pape

    (@theo38)

    One final thing – the review link; can you please give a template tag for assigned_post link?

    • This reply was modified 2 years, 11 months ago by Theo Pape.
    Plugin Author Gemini Labs

    (@geminilabs)

    One final thing – the review link; can you please give a template tag for assigned_post link?

    To show a list of assigned posts as links: {{ assigned_links }}
    To show a list of assigned posts as text: {{ assigned_posts }}
    To show a list of assigned categories as text: {{ assigned_terms }}
    To show a list of assigned users as text: {{ assigned_users }}

    Plugin Author Gemini Labs

    (@geminilabs)

    Another minor suggestion: could you please add BCC – so that we can define both the email ‘to’ and ‘bcc’? For instance, I would like to send the review to the assigned user and the admin email, but ideally the latter as BCC…

    add_filter('site-reviews/email/compose', function ($values) {
        $values['bcc'] = get_option('admin_email');
        return $values;
    });

    If you need to access the Review object inside that hook, you get it like this:

    add_filter('site-reviews/email/compose', function ($values, $email) {
        if (isset($email->data['review'])) {
            $review = $email->data['review'];
            // do something with the review object here...
        }
        return $values;
    }, 10, 2);
    Thread Starter Theo Pape

    (@theo38)

    Thanks Paul, for all of your answers. Only thing is {{ assigned_links }} – can this be used in notifications?

    i.e. in the admin here /wp-admin/edit.php?post_type=site-review&page=glsr-settings&tab=general

    {review_assigned_posts} The review's assigned page titles
    {review_assigned_users} The review's assigned user display names
    {review_author} The review author
    {review_categories} The review's assigned categories
    {review_content} The review content
    {review_email} The email of the review author
    {review_ip} The IP address of the review author
    {review_link} The link to edit/view a review
    {review_rating} The review rating number (1-5)
    {review_title} The review title
    {site_title} The Site Title from your WordPress settings
    {site_url} The Site URL from your WordPress settings
    Plugin Author Gemini Labs

    (@geminilabs)

    No. That tag is a template tag for the reviews.php template.

    Here is how you can add a custom notification tag: https://pastebin.com/EHBr2ZUd

    Thread Starter Theo Pape

    (@theo38)

    OK, how to get the assigned_links from here though?

    Thread Starter Theo Pape

    (@theo38)

    You likely have a better/cleaner way, but got it working with this:

    add_filter('site-reviews/email/compose', function ($data, $email) {
        $review = glsr_get($email->data, 'review');
        if ($review) {
            $assigned_links = get_the_permalink($email->data['review']->assigned_posts[0]);
            $data['template-tags']['assigned_links'] = $assigned_links;
        }
        return $data;
    }, 10, 2);
    Plugin Author Gemini Labs

    (@geminilabs)

    You could try something like this:

    add_filter('site-reviews/email/compose', function ($data, $email) {
        $review = glsr_get($email->data, 'review');
        if ($review) {
            $posts = $review->assignedPosts();
            $links = [];
            foreach ($posts as $post) {
                $href = get_the_permalink($post->ID);
                $name = get_the_title($post->ID);
                $links[] = sprintf('<a href="%s">%s</a>', $href, $name);
            }
            $data['template-tags']['assigned_links'] = implode(', ', $links);
        }
        return $data;
    }, 10, 2);
    Thread Starter Theo Pape

    (@theo38)

    Hmm, I don’t think $review is what you seem to think of it as, i.e. it is the HTML rather than an object? Have used this approach:

    // Add notification tag for assigned_links
    add_filter('site-reviews/email/compose', function ($data, $email) {
        $review = glsr_get($email->data, 'review');
        if ($review) {
            $posts = $email->data['review']->assigned_posts;
            $links = [];
            foreach ($posts as $post) {
                $href = get_the_permalink($post);
                $name = get_the_title($post);
                $links[] = sprintf('<a href="%s">%s</a>', $href, $name);
            }
            $data['template-tags']['assigned_links'] = implode(', ', $links);
        }
        return $data;
    }, 10, 2);
    Plugin Author Gemini Labs

    (@geminilabs)

    No. $review is the Review object. This snippet should work as given above.

    And $review = glsr_get($email->data, 'review'); is the same as $review = $email->data['review'];, except it handles the isset check for you.

    • This reply was modified 2 years, 11 months ago by Gemini Labs.
    Thread Starter Theo Pape

    (@theo38)

    OK, it doesn’t work though – pasted in exactly as your example.

    Thread Starter Theo Pape

    (@theo38)

    Error is ‘Trying to get property ‘ID’ of non-object’.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Send notification to assigned_users’ is closed to new replies.