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

    (@geminilabs)

    There is no specific hook for this, however here is a workaround that should work:

    1. Add an “api” parameter to the POST request and give it a value of true.

    2. Use the “site-reviews/review/created” hook and check for the “api” parameter in the request. If it exists, then send the notification.

    add_action('site-reviews/review/created', function ($review, $command) {
        if (wp_validate_boolean($command->request->api)) {
            glsr('Modules\Notification')->send($review);
        }
    }, 10, 2);

    If you have configured Slack notifications in the Site Reviews settings, then this will trigger the Slack notification.

    • This reply was modified 3 years, 3 months ago by Gemini Labs.
    Thread Starter datformatiebv

    (@datformatiebv)

    Excellent! Thanks you very much. That will do the trick. I noticed that the Slack payload is not equal to what is send in the email notification.
    Where can I customize / modify the Slack payload?
    Cheers

    Plugin Author Gemini Labs

    (@geminilabs)

    You can use the site-reviews/slack/compose hook to modify the Slack notification.

    See also: https://github.com/pryley/site-reviews/blob/cad03f05fa9d5ce9d385dc531a8a45eef39d1e3a/plugin/Modules/Slack.php#L42-L53

    Thread Starter datformatiebv

    (@datformatiebv)

    It seems that only post “IDs” values separated by commas can be submitted on the “Create a review” end point.

    Would it not make sense to also allow post “Title” to be submitted here?
    Or at least provide a post “Title” to post “ID” conversion query?

    With best regards,
    Edwin

    Plugin Author Gemini Labs

    (@geminilabs)

    Do you mean with the assigned_posts option?

    In WordPress, page titles and slugs can be changed. Post IDs on the other hand are unique and cannot be changed.

    If you want to assign reviews to the same page as the review form is displayed on, you can also use “post_id” as the value and Site Reviews will automatically use the Post ID of the current page (from the global $post object).

    • This reply was modified 3 years, 3 months ago by Gemini Labs.
    Thread Starter datformatiebv

    (@datformatiebv)

    Hi, what I mean is:
    When creating the payload for the “site-reviews/v1/reviews” endpoint, the assigned_posts argument only allows ” One or more IDs separated with commas.”
    Would be nice to enter Post “Title” and let the plugin figure out the post “ID”.

    Is this possible?

    Plugin Author Gemini Labs

    (@geminilabs)

    I can see how this would be useful, particularly for the API. I will think about a possible solution for a later version.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Send notification to Slack triggered via REST API’ is closed to new replies.