Version 1.0
Overview

What is Code2Prize?

Code2Prize is a self-hosted WordPress plugin purpose-built for proof-of-purchase promotions — the kind of campaigns you find under bottle caps, inside packaging, or printed on receipts. Upload your pre-printed alphanumeric codes, define your prize plan, and Code2Prize handles fair validation, winner selection, storage and notifications.

For business owners

Run a real campaign end-to-end without a developer: upload codes, set prizes, publish a page with the shortcode.

For developers

Native WP data model (wp_prize_codes, wp_prize_winners), AJAX endpoints, WPML strings and standard hooks.

1 · Installation

Install & activate

You'll receive a code2prize.zip file after purchase on CodeCanyon.

  1. 1
    Log in to wp-admin. Go to PluginsAdd NewUpload Plugin.
  2. 2
    Choose code2prize.zip and click Install Now.
  3. 3
    Click Activate. Two database tables — wp_prize_codes and wp_prize_winners — are created automatically.
  4. 4
    A new Prize menu appears in the WordPress admin sidebar.
Requirements: WordPress 6.x · PHP 8.x · MySQL / MariaDB. WooCommerce and WPML are optional.
2 · Configuration

First-time settings

Open PrizeSettings and fill in the fields below. All settings are stored as standard WordPress options.

Code2Prize settings screen
Prize → Settings: winner email, success page and shortcode reference.
Optionwp_options keyPurpose
Winner notification emailcode_validator_admin_emailAddress(es) that receive an email on every win. Falls back to WP admin_email.
Success pagecode_validator_success_pageOptional page shown to end-users after claim.
Max redemptions / devicecode_validator_max_prize_redemptions_per_deviceAnti-abuse cap per IP / device fingerprint.
Winner email subjectcode_validator_winner_email_subjectSubject line of the notification email.
Winner email bodycode_validator_winner_email_bodyHTML body. Supports the [prize_details] placeholder.
3 · Admin panel

A guided tour of wp-admin

Every screen lives under the Prize menu — no external SaaS, no separate dashboard.

Promo Draw dashboard
Dashboard: total codes, active prizes and recent activity at a glance.
Settings

Global options, shortcode reference, winner email template.

Winners

Paginated + searchable table of every winning submission with export.

Import Codes

Upload .csv, .txt or .xlsx. AJAX loader, duplicate detection.

Import Prizes

Bulk-create prize items with name, value, dates and threshold.

4 · Codes

Importing codes in bulk

Use the provided codes_template.csv — one column, one code per line. Duplicates in the file and existing rows in the database are skipped automatically.

Import Codes screen
Prize → Import Codes: drag-and-drop upload with a live import summary.
# codes_template.csv
code
ABC123XYZ
CPX7F9L2K3
CP9M2N8Q5Z
CP4J6K1T7H
# Rows are trimmed and upper-cased on import.
Supported
.csv · .txt · .xlsx
Max size
Limited by PHP upload_max_filesize
Batch
Batched INSERTs for very large files
5 · Prizes

Defining prizes

A prize is a WordPress custom entry with a name, value, an active window (start / end date) and a failed-attempts threshold — the deterministic counter that decides when the next successful code wins that prize. Bulk import via prizes_template.csv.

# prizes_template.csv
name,value,start_date,end_date,threshold,image_url
iPhone 15 (128GB),1200,2026-06-01,2026-08-31,500,https://example.com/iphone.jpg
$100 Gift Card,100,2026-06-01,2026-08-31,50,https://example.com/gift.jpg
Free Product,10,2026-06-01,2026-12-31,25,
Fair by design: the plugin uses a deterministic sequence — the Nth valid code (as configured per prize) becomes the winner. Neither admins nor end-users can predict or manipulate outcomes.
6 · Shortcodes

Rendering the entry form

Paste the primary shortcode on any page or post. That's the whole integration — no Contact Form 7, no WPForms, no Elementor required (though it plays nicely with all of them).

[code_validator_form]
ShortcodeDescription
[code_validator_form]Primary entry form. AJAX-validated.
[winner_details]Winner details capture form (name, email, phone, address).
7 · End-user flow

What your customers see

Entry form
Step 1 — the customer enters their code.
Winner claim form
Step 2 — if they win, they claim the prize with their details.
  1. Enter code → AJAX call to admin-ajax.php?action=validate_prize_code.
  2. Result → invalid, already-used, no-win, or winner.
  3. Claim → the winner form appears with the prize's featured image. Details are stored in wp_prize_winners.
  4. Notify → the site admin gets an email; the code is locked instantly.
8 · Winners

Managing winners

The Winners screen lists every claim: date, code, prize, personal details, IP and user agent. Includes search and pagination; export to CSV for fulfillment.

Winners admin table
Winners → paginated table with search & CSV export.
9 · WPML

Multilingual with WPML

Code2Prize registers per-language message strings and page IDs so the same shortcode adapts to the active language automatically.

// wp_options keys registered by the plugin
code_validator_page_id_en
code_validator_page_id_el
code_validator_msg_en_invalid
code_validator_msg_el_invalid
code_validator_msg_en_used
code_validator_msg_el_used
// ...plus success, error, winner, no-win variants.

Add a new language by duplicating the pattern code_validator_msg_<lang>_<key>. The plugin picks up the active WPML locale on the fly.

10 · Developers

Developer reference

The plugin follows standard WordPress conventions: text domain code2prize, translations in /languages, all AJAX calls routed through admin-ajax.php.

AJAX endpoints

ActionMethodPurpose
validate_prize_codePOSTValidate a submitted code, return status & prize.
submit_winner_detailsPOSTPersist winner form & trigger admin email.
code2prize_import_codesPOSTAdmin-only bulk import handler.
code2prize_import_prizesPOSTAdmin-only prize import handler.

Sample cURL — validate a code

curl -X POST https://example.com/wp-admin/admin-ajax.php \
  -d "action=validate_prize_code" \
  -d "code=CPX7F9L2K3" \
  -d "nonce=<wp_nonce>"

Sample response

{
  "success": true,
  "data": {
    "status": "winner",
    "prize_id": 42,
    "prize_name": "iPhone 15 (128GB)",
    "image": "https://…/iphone.jpg"
  }
}
11 · Schema

Database schema

Both tables are created via dbDelta() on activation and re-checked on load.

wp_prize_codes

id            BIGINT UNSIGNED  PK, AUTO_INCREMENT
code          VARCHAR(255)     UNIQUE
status        VARCHAR(50)      -- pending | used | won
use_date      DATETIME
prize_id      BIGINT UNSIGNED
created_at    DATETIME         DEFAULT CURRENT_TIMESTAMP

wp_prize_winners

id            BIGINT UNSIGNED  PK, AUTO_INCREMENT
code          VARCHAR(255)
prize_id      BIGINT UNSIGNED
prize_name    VARCHAR(255)
full_name     VARCHAR(255)
email         VARCHAR(255)
phone         VARCHAR(50)
address       TEXT
ip_address    VARCHAR(45)
user_agent    TEXT
win_date      DATETIME         DEFAULT CURRENT_TIMESTAMP
sequence      INT
12 · Hooks

Filters & actions

Extend or override behavior from your own theme / plugin.

// Send winner notifications to Slack as well as email
add_action('code2prize_after_winner_saved', function($winner) {
  wp_remote_post('https://hooks.slack.com/…', [
    'body' => wp_json_encode([
      'text' => "🎉 New winner: {$winner['full_name']} — {$winner['prize_name']}",
    ]),
  ]);
});

// Customize the winner email body
add_filter('code2prize_winner_email_body', function($body, $winner) {
  return "Hi {$winner['full_name']},\n\n" . $body;
}, 10, 2);
13 · Help

FAQ & troubleshooting

Codes aren't validating — what should I check?

Confirm the shortcode is on a published page, that the code exists in wp_prize_codes (case-sensitive after trim/upper), and check the browser console for the AJAX response.

The winner email never arrives.

WordPress uses PHP mail() by default. Install an SMTP plugin (e.g. WP Mail SMTP) and re-test.

Can I reset a campaign?

Truncate wp_prize_codes and wp_prize_winners, then re-import your codes.

Does it work with WooCommerce?

Yes. Code2Prize runs alongside WooCommerce with no conflicts and can be embedded on any WooCommerce page via the shortcode.

How do I uninstall cleanly?

Deactivating keeps your data. Deleting from Plugins fires register_uninstall_hook, which drops both tables and removes all code_validator_* options.

Launch your next promotion ASAP

One plugin. One-time price. Unlimited codes. The fairest way to run a proof-of-purchase campaign on WordPress.