Refinery Reviews offers WordPress actions and filters so developers can react to reviews, change which products a review request asks about, adjust what is shown, and add data to Klaviyo events or the Google feed. This article lists the public hooks with their parameters. Add the code to a small custom plugin or the child theme’s functions.php, never to the plugin’s own files, which updates replace.
Reviews are WooCommerce product reviews (comments with the type review, rating in the comment meta rating), so WordPress’s comment hooks such as comment_post and transition_comment_status work too. Hooks marked (Pro) only run in Refinery Reviews Pro.
Prerequisites
- Comfort with PHP and WordPress hooks.
- A staging site to test changes. A filter that returns the wrong type can stop review requests or break the reviews section.
Actions
| Action | Parameters | Fires |
|---|---|---|
refinery_reviews_submitted | int $review_id, string $status (approved or held) | After a customer submits a review, from the product page or a request link. Not for imports. |
refinery_reviews_request_submitted | array $request, int[] $review_ids | After reviews are submitted from a review request page. |
refinery_reviews_store_replied | int $reply_id, int $review_id | After the store replies to a review from Refinery -> Reviews. |
refinery_reviews_request_scheduled | int $request_id, WC_Order $order | After a review request is scheduled for an order that reached the trigger status. |
refinery_reviews_request_sent | int $request_id, WC_Order $order | After a review request goes out, by email or (Pro) handed to Klaviyo. Not for reminders. |
refinery_reviews_requests_turned_off | None | When the store turns automatic review requests off (waiting requests are canceled). |
refinery_reviews_reward_issued | WC_Coupon $coupon, WC_Order $order | After a review reward code is issued. |
refinery_reviews_opted_out | string $email | After an email address opts out of review requests. |
refinery_reviews_after_reviews | int $product_id | Inside the reviews section, after the list. Print extra markup here. |
refinery_reviews_question_answered (Pro) | int $answer_id, int $question_id | After the store answers a product question. |
The $request array has the request’s columns, including id, order_id, email, status and items (with products, the product IDs asked about, and reviewed, the product IDs reviewed so far).
Filters
| Filter | Parameters | Use |
|---|---|---|
refinery_reviews_request_items | int[] $product_ids, WC_Order $order | The products a review request asks about, after the built-in rules. Return an empty array to send nothing. |
refinery_reviews_request_delay | int $seconds, WC_Order $order | How long after the order reaches the status the request is sent, in seconds. |
refinery_reviews_display_name | string $name, WP_Comment $review | The name shown for a review. |
refinery_reviews_show_form | bool $show, int $product_id | Whether the review form is shown in the reviews section. |
refinery_reviews_review_html | string $html, WP_Comment $review, WP_Comment[] $replies | One review’s markup. Return escaped HTML. |
refinery_reviews_reward_coupon | WC_Coupon $coupon, WC_Coupon $template, WC_Order $order | The reward coupon before it is saved. Return a WC_Coupon. |
refinery_reviews_rate_limit | int $limit, string $bucket | A public endpoint’s rate limit. Buckets: submit (reviews per hour), captcha (captcha checks per hour), link_miss (wrong review links per hour), link_{id} (tries on one review link per hour), vote (helpful votes per minute), vote_review_{id} (guest votes on one review per day) and question (questions per hour, Pro). Return 0 to turn the limit off. |
refinery_reviews_client_ip | string $ip | The visitor IP used for rate limiting, for example from a trusted proxy header. Only a hash of it is kept, for at most the limit window. |
refinery_reviews_klaviyo_event_properties (Pro) | array $properties, string $name (event name without the “Reviews: ” prefix), string $email | A Klaviyo event’s properties. |
refinery_reviews_klaviyo_profile (Pro) | array $properties, string $email | The review properties synced to a Klaviyo profile. |
refinery_reviews_feed (Pro) | array $feed | The Klaviyo reviews web feed (store, updated, recent, products). |
refinery_reviews_google_feed_product_ids (Pro) | array $ids (gtin, mpn, sku, brand, name, url), WC_Product $product | A product’s identifiers in the Google reviews feed, for stores that keep the GTIN, MPN or brand somewhere else. |
Examples
Send review requests 14 days after the order reaches its status for orders shipped abroad, instead of the setting:
add_filter( 'refinery_reviews_request_delay', function ( $seconds, $order ) {
if ( 'US' !== $order->get_shipping_country() ) {
return 14 * DAY_IN_SECONDS;
}
return $seconds;
}, 10, 2 );
Read the GTIN from a custom field in the Google reviews feed (Pro):
add_filter( 'refinery_reviews_google_feed_product_ids', function ( $ids, $product ) {
if ( '' === $ids['gtin'] ) {
$ids['gtin'] = (string) $product->get_meta( '_my_barcode' );
}
return $ids;
}, 10, 2 );
Add the product’s category names to every Klaviyo event (Pro):
add_filter( 'refinery_reviews_klaviyo_event_properties', function ( $properties, $name, $email ) {
if ( ! empty( $properties['ProductID'] ) ) {
$properties['Categories'] = wp_list_pluck( get_the_terms( $properties['ProductID'], 'product_cat' ) ?: [], 'name' );
}
return $properties;
}, 10, 3 );
Data the plugin stores
- Extra review data is comment meta with the
_refinery_reviews_prefix, for example_refinery_reviews_title,_refinery_reviews_featuredand_refinery_reviews_source. - Tables:
{prefix}refinery_reviews_requests,{prefix}refinery_reviews_votesand{prefix}refinery_reviews_optouts. - Settings: the
refinery_reviews_settingsoption. - Background jobs run in the Action Scheduler group
refinery-reviews; Klaviyo sends (Pro) run inrefinery_klaviyo.
Troubleshooting
- A filter has no effect. Check the number of accepted arguments in
add_filter()matches the parameters used, and that the code loads before the hook runs (a plugin, or the theme’sfunctions.php). - Requests stop after adding
refinery_reviews_request_items. The filter must return an array of product IDs; an empty array means nothing to ask about, and the request is skipped. - A Pro hook never runs. It only exists in Refinery Reviews Pro, and the Klaviyo hooks only run while Klaviyo is on.