The uspw_after_prize_selected Action Hook
uspw_after_prize_selected is an action that fires on the server the moment the winning slice has been drawn and its coupon code resolved, but before the JSON response is returned to the visitor’s browser. It is the ideal place to send real-time notifications, write to a custom log or table, or push conversion events to an external service. Available since version 1.0.0.
Important: this hook requires the Pro add-on
In Ultimate Spin Wheel, every uspw_* developer hook is wrapped in a Pro gate. The plugin only runs do_action( 'uspw_after_prize_selected', ... ) when apply_filters( 'ultimate_spin_wheel_pro_init', false ) returns true — which happens only when the separate Ultimate Spin Wheel Pro plugin is installed and active. On the free plugin alone this action never fires, so any callback you attach will simply not run until Pro is active.
Parameters
The action passes four arguments, so register it with an accepted-args count of 4:
$selected_prize(array): The winning slice’s stored data. Real keys arelabel,code,color,coupon_type,probability,is_unique, and (when set)image_urlandmessage. There is novalue,id, orimage_idkey — do not rely on those.$campaign_id(int): The ID of the spin wheel campaign (a WordPress post ID).$user_data(array): The submitted lead data, containing exactlyemail,name, andphone. Note that phone capture itself is a Pro feature, sophoneis often an empty string.$won_code(string): The actual coupon code assigned to this winner. For a Unique Pool slice this is the specific code that was just consumed; for a Lose (No Prize) slice it is typically empty.
Basic Usage
Attach a callback with add_action( 'uspw_after_prize_selected', 'my_prize_handler', 10, 4 ); and declare the four parameters in your function: function my_prize_handler( $selected_prize, $campaign_id, $user_data, $won_code ) { ... }. Inside, read the slice label with $selected_prize['label'] ?? '' and detect a losing spin by checking whether ( $selected_prize['coupon_type'] ?? 'static' ) === 'lose'.
Real-World Use Cases
Send real-time winner notifications
Alert your team the instant someone wins. In your callback, skip losing spins by returning early when coupon_type is lose, then post to a Slack incoming webhook with wp_remote_post() and/or send an email with wp_mail(). Build the message from $selected_prize['label'], $won_code, $user_data['email'], and $campaign_id. Because there is no numeric value field, target “high-value” prizes by matching the slice label or by keying off which $campaign_id fired.
Log wins to a custom table
Keep your own audit trail alongside the plugin’s built-in wp_wdengage_entries table. Use $wpdb->insert() to record $campaign_id, $selected_prize['label'], $selected_prize['probability'], $won_code, $user_data['email'], and current_time( 'mysql' ). This is handy for reconciling redemptions or for reporting on Unique Pool consumption over time.
Push conversion events to analytics or a CRM
Forward each win as a server-side event to a third-party endpoint with wp_remote_post() — for example a custom analytics API, a data warehouse, or a marketing platform. Send the slice label, the $won_code, the winner’s email, and the $campaign_id in a JSON body. Note that Ultimate Spin Wheel Pro already ships native integrations for Mailchimp, MailPoet, Klaviyo, ActiveCampaign, HubSpot, Zapier, and Pabbly, so reach for this hook only when you need a destination those integrations do not cover.
Notes & Gotchas
- The hook fires before the response is sent, so heavy work (slow HTTP calls) will delay the visitor’s result. For anything non-trivial, offload to
wp_schedule_single_event()or a background queue. - This action runs on the modern secure
process_spinAJAX path. The winner is drawn on the server withwp_rand()before the wheel animates, so$selected_prizeand$won_codeare final and trustworthy at this point. - A losing spin only happens when a Lose (No Prize) slice (a Pro slice type) is configured and drawn. For those,
coupon_typeisloseand$won_codeis empty — guard against empty codes accordingly. - Do not read
$selected_prize['value'],['id'], or['image_id']— those keys do not exist. Uselabel,coupon_type,probability, andimage_urlinstead.
Related Documentation
- Hooks & Filters Reference: The full list of
uspw_*actions and filters, all of which require the Pro add-on. - Win Probabilities: How the server draws the winning slice before this hook fires.
- Prize & Coupon Configuration: Static codes, Unique Pools, Lose slices, and the fields that populate
$selected_prize.
Conclusion
The uspw_after_prize_selected action gives Pro developers a clean, server-side seam to react to every confirmed win — notifications, logging, and external integrations — with the final prize and coupon code in hand. Remember it only fires when Ultimate Spin Wheel Pro is active, keep your callbacks fast, and read only the fields that actually exist on $selected_prize. For help, visit the wowDevs support center.