Launch Sale: 20% off all plugins. Limited time only.

Developer hooks

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

ActionParametersFires
refinery_reviews_submittedint $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_submittedarray $request, int[] $review_idsAfter reviews are submitted from a review request page.
refinery_reviews_store_repliedint $reply_id, int $review_idAfter the store replies to a review from Refinery -> Reviews.
refinery_reviews_request_scheduledint $request_id, WC_Order $orderAfter a review request is scheduled for an order that reached the trigger status.
refinery_reviews_request_sentint $request_id, WC_Order $orderAfter a review request goes out, by email or (Pro) handed to Klaviyo. Not for reminders.
refinery_reviews_requests_turned_offNoneWhen the store turns automatic review requests off (waiting requests are canceled).
refinery_reviews_reward_issuedWC_Coupon $coupon, WC_Order $orderAfter a review reward code is issued.
refinery_reviews_opted_outstring $emailAfter an email address opts out of review requests.
refinery_reviews_after_reviewsint $product_idInside the reviews section, after the list. Print extra markup here.
refinery_reviews_question_answered (Pro)int $answer_id, int $question_idAfter 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

FilterParametersUse
refinery_reviews_request_itemsint[] $product_ids, WC_Order $orderThe products a review request asks about, after the built-in rules. Return an empty array to send nothing.
refinery_reviews_request_delayint $seconds, WC_Order $orderHow long after the order reaches the status the request is sent, in seconds.
refinery_reviews_display_namestring $name, WP_Comment $reviewThe name shown for a review.
refinery_reviews_show_formbool $show, int $product_idWhether the review form is shown in the reviews section.
refinery_reviews_review_htmlstring $html, WP_Comment $review, WP_Comment[] $repliesOne review’s markup. Return escaped HTML.
refinery_reviews_reward_couponWC_Coupon $coupon, WC_Coupon $template, WC_Order $orderThe reward coupon before it is saved. Return a WC_Coupon.
refinery_reviews_rate_limitint $limit, string $bucketA 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_ipstring $ipThe 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 $emailA Klaviyo event’s properties.
refinery_reviews_klaviyo_profile (Pro)array $properties, string $emailThe review properties synced to a Klaviyo profile.
refinery_reviews_feed (Pro)array $feedThe 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 $productA 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_featured and _refinery_reviews_source.
  • Tables: {prefix}refinery_reviews_requests, {prefix}refinery_reviews_votes and {prefix}refinery_reviews_optouts.
  • Settings: the refinery_reviews_settings option.
  • Background jobs run in the Action Scheduler group refinery-reviews; Klaviyo sends (Pro) run in refinery_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’s functions.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.

Grow Your Store Smarter

One email a week with plugin updates, revenue tactics, and strategies top WooCommerce stores use to scale.

By subscribing, you agree to receive emails from Refinery and to our Privacy Policy. Unsubscribe anytime.

Item added to cart.
0 items - $0.00