Ultimate Spin Wheel provides 8 powerful PHP action hooks that allow developers to extend and customize the plugin’s functionality without modifying core files.
Overview
All hooks are prefixed with uspw_ and follow WordPress naming conventions. They are strategically placed at key points in the spin wheel flow to provide maximum flexibility.
Hook Execution Order
The hooks fire in the following sequence during a spin:
uspw_before_spin_validation – Before any validationuspw_before_prize_selection – Before random selection algorithmuspw_after_prize_selected – After prize is selecteduspw_after_coupon_won – After coupon is awarded (legacy flow)uspw_before_save_entry – Before saving to databaseuspw_after_entry_saved – After database insertuspw_before_send_winner_email – Before email is sentuspw_email_sent_result – After email send attempt
Available Hooks
1. uspw_before_spin_validation
Type: Filter
Location: class-spin-wheel.php (line ~337)
Purpose: Custom validation before spin processing
$can_spin = apply_filters( 'uspw_before_spin_validation', true, $campaign_id, $user_data );
Parameters:
bool $can_spin – Whether the user can spin (default: true)int $campaign_id – Campaign IDarray $user_data – User submitted data
Common Use Cases:
- Block spins from specific email domains
- Implement custom rate limiting
- Require user authentication
- Validate custom fields
- Time-based restrictions
2. uspw_before_prize_selection
Type: Action
Location: class-spin-wheel.php (line ~409)
Purpose: Analytics and tracking before prize selection
do_action( 'uspw_before_prize_selection', $campaign_id, $weighted_prizes, $user_data );
Parameters:
int $campaign_id – Campaign IDarray $weighted_prizes – Available prizes with weightsarray $user_data – User submitted data
Common Use Cases:
- Track prize pool analytics
- Implement A/B testing
- Send real-time notifications
- Log user behavior patterns
- Integrate with external CRM
3. uspw_after_prize_selected
Type: Action
Location: class-spin-wheel.php (line ~485)
Purpose: Post-selection actions and notifications
do_action( 'uspw_after_prize_selected', $selected_prize, $campaign_id, $user_data, $won_code );
Parameters:
array $selected_prize – The winning prize detailsint $campaign_id – Campaign IDarray $user_data – User submitted datastring $won_code – The actual coupon code won
Common Use Cases:
- Send real-time winner notifications
- Track prize inventory
- Trigger marketing automation
- Create custom post for each winner
- Sync with analytics platforms
4. uspw_after_coupon_won
Type: Action
Location: class-spin-wheel.php (line ~270)
Purpose: Custom notifications after coupon is won (legacy spin flow)
do_action( 'uspw_after_coupon_won', $campaign_id, $data );
Parameters:
int $campaign_id – Campaign IDarray $data – Entry data including coupon_code, coupon_title, email, name
Common Use Cases:
- Send SMS notifications to winners
- Trigger custom webhook for each win
- Log wins to external analytics
- Update inventory systems
- Sync with loyalty programs
5. uspw_before_save_entry
Type: Filter
Location: class-spin-wheel.php (line ~590)
Purpose: Modify or enrich data before database save
$data = apply_filters( 'uspw_before_save_entry', $data, $campaign_id );
Parameters:
array $data – Entry dataint $campaign_id – Campaign ID
Common Use Cases:
- Add UTM parameters for attribution
- Enrich data with geolocation
- Normalize phone numbers
- Calculate lead quality scores
- Integrate with email verification
6. uspw_after_entry_saved
Type: Action
Location: class-spin-wheel.php (line ~628)
Purpose: External integrations after database save
do_action( 'uspw_after_entry_saved', $entry_id, $data, $campaign_id );
Parameters:
int $entry_id – Database entry IDarray $data – Complete entry dataint $campaign_id – Campaign ID
Common Use Cases:
- Sync with CRM (Salesforce, HubSpot)
- Trigger Zapier webhooks
- Create WooCommerce customers
- Send to Google Sheets
- Queue background jobs
7. uspw_before_send_winner_email
Type: Filter
Location: class-spin-wheel.php (line ~665)
Purpose: Customize email before sending
$email_args = apply_filters( 'uspw_before_send_winner_email', $email_args, $data, $campaign_id );
Parameters:
array $email_args – Email parameters (to, subject, message, headers)array $data – Entry dataint $campaign_id – Campaign ID
Common Use Cases:
- Translate emails by location
- Route to transactional email service
- Add product recommendations
- Add expiration timers
- A/B test email templates
8. uspw_email_sent_result
Type: Action
Location: class-spin-wheel.php (line ~681)
Purpose: Handle email delivery results
do_action( 'uspw_email_sent_result', $email_sent, $data, $campaign_id );
Parameters:
bool $email_sent – Whether email was sent successfullyarray $data – Entry dataint $campaign_id – Campaign ID
Common Use Cases:
- Log email delivery status
- Implement retry logic
- Send SMS fallback
- Track email performance
- Sync status with CRM
Best Practices
1. Use Appropriate Priority
// Default priority (10)
add_action( 'uspw_after_entry_saved', 'my_function', 10, 3 );
// Run early (5)
add_action( 'uspw_before_save_entry', 'my_validation', 5, 2 );
// Run late (20)
add_action( 'uspw_after_entry_saved', 'my_cleanup', 20, 3 );
2. Always Validate Data
add_action( 'uspw_after_prize_selected', 'my_handler', 10, 4 );
function my_handler( $selected_prize, $campaign_id, $user_data, $won_code ) {
// Validate inputs
if ( empty( $user_data['email'] ) ) {
return;
}
// Sanitize data
$email = sanitize_email( $user_data['email'] );
// Your logic here
}
3. Use Asynchronous Processing for Heavy Operations
add_action( 'uspw_after_entry_saved', 'queue_heavy_task', 10, 3 );
function queue_heavy_task( $entry_id, $data, $campaign_id ) {
// Schedule background job instead of running immediately
wp_schedule_single_event( time() + 60, 'my_heavy_task', [
'entry_id' => $entry_id,
'data' => $data
] );
}
4. Handle Errors Gracefully
add_action( 'uspw_after_entry_saved', 'sync_to_api', 10, 3 );
function sync_to_api( $entry_id, $data, $campaign_id ) {
$response = wp_remote_post( 'https://api.example.com/endpoint', [
'body' => wp_json_encode( $data )
] );
if ( is_wp_error( $response ) ) {
error_log( 'API sync failed: ' . $response->get_error_message() );
// Don't break the user experience
return;
}
}
5. Respect Pro Plugin Compatibility
add_action( 'uspw_before_prize_selection', 'my_custom_logic', 10, 3 );
function my_custom_logic( $campaign_id, $weighted_prizes, $user_data ) {
// Check if Pro is active
$is_pro = apply_filters( 'ultimate_spin_wheel_pro_init', false );
if ( $is_pro ) {
// Pro-specific logic
} else {
// Free version logic
}
}
Code Examples Repository
Each hook has its own documentation page with 5 real-world code examples:
- uspw_before_spin_validation – Validation & blocking examples
- uspw_before_prize_selection – Analytics & tracking examples
- uspw_after_prize_selected – Notification & inventory examples
- uspw_after_coupon_won – Custom notification examples
- uspw_before_save_entry – Data enrichment examples
- uspw_after_entry_saved – CRM integration examples
- uspw_before_send_winner_email – Email customization examples
- uspw_email_sent_result – Delivery tracking examples
Support
For questions or issues with these hooks:
- Check the individual hook documentation pages
- Review the code examples for similar use cases
- Examine the source code inÂ
includes/core/class-spin-wheel.php - Contact support with specific implementation questions
Version History
- 1.5.0 (Pro)Â – Initial release with all 8 hooks
Last Updated: February 2026