=== Squad Affiliate – Affiliate Program & Referral Plugin for WooCommerce and Divi ===
Contributors: wpsquad
Tags: affiliate, affiliate marketing, affiliate program, referral, woocommerce affiliate
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Affiliate program plugin for WooCommerce and Divi. Self-hosted referral tracking, flexible affiliate commissions, and affiliate payouts.

== Description ==

**Squad Affiliate — the self-hosted affiliate program and referral plugin for WordPress, WooCommerce and Divi.**

Run your own affiliate program directly in WordPress: recruit affiliates, track referrals, calculate commissions and pay partners — with no SaaS platform fees, no per-sale cut, and no third-party cookies.

Affiliate tracking is self-hosted and first-party, so referrals keep being
credited when ad blockers strip third-party scripts, and your affiliate data stays
in your own database rather than on someone else's analytics platform.

Squad Affiliate is an affiliate marketing plugin built for real stores. It tracks
WooCommerce and Easy Digital Downloads sales, memberships, courses and donations;
it handles percentage, flat, tiered, recurring and lifetime commissions; and it
gives every affiliate a dashboard where they can find their referral link, their
clicks, their earnings and their payout history.

It is also built to feel at home in a Divi 5 site: the affiliate registration form
and the affiliate dashboard are real builder modules you drop onto a page, and
shortcodes cover every other theme.

= Why a self-hosted affiliate plugin =

Hosted affiliate platforms charge a monthly fee, take a percentage of the
commissions you pay, and keep your referral data. A self-hosted affiliate program
costs nothing per sale, keeps every affiliate record in your own WordPress
install, and works with the checkout you already run.

= How attribution works =

A visitor who arrives through an affiliate's referral link is remembered with a
first-party cookie. When that visitor buys, the order is credited to the
affiliate. You can also tie a WooCommerce coupon or an Easy Digital Downloads
discount code to an affiliate, so a purchase that applies the code is credited
even without a referral link. When both apply, the referral link wins.

= Lite (this plugin) includes =

* Unlimited affiliates with first-party, ad-blocker-resistant tracking.
* Referral-link, coupon-code and direct-link attribution — a link parameter, a
  vanity slug (`?ref=jane`), an affiliate's coupon, or simply the site they
  referred the visitor from.
* Short links: every affiliate can create `/go/…` links on your domain that credit
  them and forward to any page — one of yours or one on another site.
* An affiliate who owns a website can ask that it be registered as a direct-link
  domain, from their own dashboard; you approve or decline the request. Nothing is
  credited, and no visitor is reattributed, until you say yes.
* Commissions: flat, percentage, per-affiliate override, and a rule engine for
  per-product, per-category, per-role, per-campaign and volume-tier rates.
  Recurring (subscription renewals), lifetime (a referred customer's later
  orders), multi-level overrides, signup bonuses, performance bonuses and
  pay-per-lead all ship free.
* Choose what a commission is a percentage of: exclude shipping and tax, or pay
  on net revenue.
* Large commissions can be held for review instead of approved automatically.
* Affiliate registration with manual or automatic approval, and a self-service
  dashboard where affiliates see their referrals, clicks, earnings, team and
  payout details.
* Affiliate groups with their own rates, and a leaderboard.
* Divi 5 modules — Affiliate Registration Form and Affiliate Dashboard — plus
  shortcodes for the whole portal or any single screen:
  `[squad_affiliate_dashboard]`, `[squad_affiliate_login]`,
  `[squad_affiliate_register]`, `[squad_affiliate_apply]`.
* Personalised landing pages, built in whichever page builder you already use.
  `[squad_affiliate_referrer]` prints the name (or company, website, country) of
  the affiliate who sent the visitor, `[squad_affiliate_coupon]` prints their
  code, and `[squad_affiliate_if_referred]` / `[squad_affiliate_if_not_referred]`
  wrap the content that should only appear for one of the two.
* A creatives library — banners, text links, email swipe copy and social posts —
  plus a banner builder: pick a standard ad size, write the copy, and the banner
  is generated, added to your media library and saved as a creative.
* WooCommerce (HPOS-aware) and Easy Digital Downloads referral tracking, with
  self-referral and one-referral-per-order guards.
* Memberships, courses and fundraising too: MemberPress, LifterLMS, Paid
  Memberships Pro, LearnDash, SureCart and GiveWP, plus lead commissions from
  Contact Form 7, Gravity Forms, WPForms and Fluent Forms.
* Payouts: approve and mark as paid by hand, export a plain batch CSV, or pay
  through store credit an affiliate spends on your shop or a bank transfer you
  record once sent. Affiliates choose which of those rails they get paid
  through and can request a withdrawal.
* Reports: earnings over time, per-source and per-campaign performance,
  conversion rates, and a monthly summary email.
* Transactional emails you can edit, preview and test-send, with your own logo,
  colour and footer.
* One-click migration from eighteen other affiliate plugins, plus a CSV path for
  anything else — affiliates, commission history and click logs.
* Sample data on request: a complete demo programme you can remove again in one
  click, for trying the screens before you have real affiliates.
* An Abilities API surface and an MCP server, so an AI agent can read your
  programme with the same capability checks a person gets.
* Privacy tools: GDPR personal-data export and erasure.

= Squad Affiliate Pro adds =

* AI fraud scoring at ingestion — a deterministic scorer plus a plain-English
  explanation written through WordPress's own AI Client; suspicious commissions
  are auto-held, never auto-paid (and it fails open: an AI outage never blocks
  your store).
* MLM matrix topologies — Unilevel, Binary, and Forced network trees.
* The PayPal Payouts API, Stripe Connect and Wise bulk-payment files as payout
  rails, plus the PayPal- and Wise-shaped CSV exports each provider's own
  upload tool expects.
* Automated and scheduled payout dispatch (hands-off, one-click runs), and
  loyalty points as a payout rail.
* Server-side (S2S) conversion tracking for cookieless attribution.
* Multiple programs / campaigns and affiliate networks (run several merchants).
* Affiliate ranks with rate bonuses, influencer retainers, pay-per-click
  commissions, and customer advocacy (turn buyers into affiliates).
* Custom registration fields, and branded short links — affiliates name their own
  link (`/go/jane`) instead of taking the generated one. Short links themselves
  are free.
* Smart links: one printed link that sends a phone, a desktop, or a visitor in
  another country to a different page, without reprinting the link.
* Team roles and permissions, and an audit log of every administrative action.
* Tax / KYC collection (W-9 / W-8 / 1099) with a payout gate and year-end
  reports, Zapier / Make automation, FluentCRM sync, and affiliate broadcasts.

Squad Affiliate's goal is competitive parity in the free build: Pro is reserved
for the differentiators above, not for the features every other plugin charges
for.

Squad Affiliate is part of the Squad family by WP Squad, the team behind Squad
Modules for Divi.

Documentation, guides and the Pro comparison: https://squadaffiliate.com/

== Installation ==

1. Upload the plugin to `/wp-content/plugins/squad-affiliate`, or install it from
   the Plugins screen in your dashboard.
2. Activate it. The custom tables are created automatically on activation.
3. Open Squad Affiliate in the admin menu to review pending affiliates and
   payouts.
4. Add the Affiliate Registration Form and Affiliate Dashboard modules to a page
   in the Divi builder, or place the `[squad_affiliate_dashboard]` shortcode on
   any page.
5. Optional: give each step its own page with `[squad_affiliate_login]` (sign in),
   `[squad_affiliate_register]` (create an account) and `[squad_affiliate_apply]`
   (join the program). `[squad_affiliate_dashboard]` already covers all three on
   one page, so use these only if you want separate URLs.

== Frequently Asked Questions ==

= Does it use third-party cookies? =

No. Tracking is self-hosted and first-party, so it resists ad blockers and is
friendlier to privacy regulations.

= How do affiliates get credited for a sale? =

Two ways. A referral link sets a first-party cookie that credits the affiliate
when the visitor buys. Alternatively, you can assign a WooCommerce coupon or an
EDD discount code to an affiliate from the coupon editor; any order that applies
that code is credited. If a visitor has both a referral cookie and a mapped
coupon, the referral cookie takes precedence.

= How do I link a coupon to an affiliate? =

Edit the WooCommerce coupon and enter the affiliate's ID in the "Affiliate ID"
field. From then on, orders using that coupon are attributed to that affiliate.

= Do I need WooCommerce? =

WooCommerce or Easy Digital Downloads is recommended for automatic referral
tracking on purchases, but the affiliate program itself works independently.

= How are affiliates paid? =

Approve pending commissions and mark them as paid by hand, pay through store
credit or a bank transfer, or export a plain batch CSV — all free, and
affiliates choose which of those rails they get paid through. The PayPal
Payouts API, Stripe Connect and Wise bulk-payment files, the PayPal- and
Wise-shaped CSV exports, and running batches automatically on a schedule are
Squad Affiliate Pro.

= Can I try the screens before I have any affiliates? =

Yes. Settings has a sample-data importer that builds a complete demo programme —
affiliates in tiers with a referral network, sales and leads across every status,
campaign-tagged clicks, coupons, creatives, withdrawal requests and payout
batches — and removes exactly what it created when you are done. The accounts it
makes use addresses reserved for documentation, so they cannot receive mail, and
no notification is sent while it runs. Use it on a development or staging site.

= What happens to the AI features if the service is down? =

Fraud scoring is advisory and fails open: referrals are approved as normal and
flagged as "degraded" for later review. Your tracking and payouts are never
blocked. In Lite, no AI endpoint is configured by default, so no external
request is made at all.

== External services ==

Referral tracking, commission calculation and payouts are all handled locally by
your own WordPress installation. Out of the box the plugin contacts nothing. Each
service below waits on a decision of yours — a setting you fill in, a dialog you
approve, or a permissions screen you accept — and each one names the address it
would reach; none of them is required to run an affiliate program.

= Outgoing webhooks (optional, off by default) =

If — and only if — you enter one or more webhook URLs under Settings, the plugin
sends an HTTP POST to each of those addresses on two events: when a referral is
recorded, and when a payout completes. You choose the addresses, so you choose
the service: your own endpoint, an automation tool such as Zapier or Make, or
nothing at all.

A referral event sends the referral and affiliate IDs, the commission amount and
currency, the order ID and the status. A payout event sends the payout ID and the
payout method. No visitor IP addresses, no customer names or addresses, and no
order contents are included. Leaving the webhook URL setting empty means no
request is ever made.

Because the destination is whatever you enter, its terms and privacy policy are
the terms and privacy policy of the service you point it at.

= Sample-data download (optional, off by default, asks first) =

The sample-data importer works entirely offline: a dictionary of names, tiers,
amounts and campaigns is built into the plugin, so pressing Import never contacts
anything.

Richer and translated dictionaries live in a companion public repository on
GitHub. Downloading them is a separate button, and it is refused until you have
explicitly approved the download in a dialog that names the address — no request
happens before you say yes. The request is a plain GET for a zip of
https://github.com/thewpsquad/squad-affiliate-sample-data ; nothing about your
site, your affiliates or your visitors is sent, and the archive is unpacked into
your own uploads directory. You can delete the downloaded copy at any time and
the importer falls back to the built-in dictionary.

GitHub's terms and privacy statement apply to that download:
https://docs.github.com/site-policy

= AI fraud scoring =

Earlier builds could optionally call an external AI risk-scoring service. That
service has been retired and the setting that enabled it is gone. Fraud scoring
is available in Squad Affiliate Pro, where it runs locally: a deterministic PHP
scorer, with the optional plain-English explanation going through WordPress's own
AI Client — so the provider is whichever one you have installed and keyed, and
Squad Affiliate has no AI service of its own.

= Freemius (licensing and product analytics, opt-in) =

Squad Affiliate uses the Freemius service to deliver Squad Affiliate Pro and its
updates, and — only if you consent — anonymous usage diagnostics. Freemius runs on
an explicit opt-in: on activation you are shown a permissions screen and can
**skip** it. No data is sent to Freemius unless you opt in, or you activate a Pro
licence.

When enabled, the data sent may include: your site URL, WordPress and PHP
versions, the administrator email address, active plugin and theme information,
and the Squad Affiliate version. It is used for licence validation, update
delivery and product analytics. Nothing about your affiliates, your referrals,
your commissions or your visitors is ever sent.

* Service: [Freemius](https://freemius.com/)
* Terms of Service: https://freemius.com/terms/
* Privacy Policy: https://freemius.com/privacy/

== Screenshots ==

1. The Overview screen: earnings, referrals, conversion rate and pending payouts for the period, with the top affiliates and the most recent referrals beside them.
2. The Affiliates screen, showing each partner's status, group, referral total and unpaid balance. Approve, reject and edit happen inline.
3. The Referrals screen. Every referral carries the order it came from, the commission it earned, how it was attributed (link, coupon or referring domain) and its fraud verdict.
4. Commission rules: percentage or flat, per product, category, group or affiliate, with a first-order bonus and recurring-commission settings.
5. The Payouts screen. Unpaid balances are gathered into a batch, reviewed, then marked paid or exported as CSV for your own payment run.
6. Reports: earnings and referrals over time, with per-affiliate, per-product and per-source breakdowns and a leaderboard.
7. The affiliate's own portal on the front end, where partners find their referral link, QR code, creatives and payout history.

== Changelog ==

= 1.0.0 =
* First-party, ad-blocker-resistant referral tracking, with vanity slugs, QR
  codes, short links and direct-link (referring-domain) attribution.
* Coupon-code attribution: map a WooCommerce coupon or EDD discount code to an
  affiliate from the coupon editor, or auto-generate one per affiliate; the
  referral-link cookie takes precedence when both apply.
* Affiliate registration (manual or auto approval), a React self-service portal
  (referrals, clicks, creatives, team, payout details, withdrawals) and a full
  admin dashboard with reports.
* Referral creation on WooCommerce (HPOS-aware) orders and Easy Digital Downloads
  purchases, with self-referral and one-per-order guards — plus MemberPress,
  LifterLMS, Paid Memberships Pro, LearnDash, SureCart, GiveWP, and lead
  commissions from Contact Form 7, Gravity Forms, WPForms and Fluent Forms.
* Commission rule engine: per-product, per-category, per-role, per-campaign and
  volume-tier rates, on top of flat, percentage and per-affiliate overrides.
  Recurring, lifetime, multi-level, signup and performance bonuses included;
  shipping/tax exclusion and net-revenue share configurable.
* Refund reversal, and a review hold for commissions above a threshold.
* Payouts: approve, mark-as-paid, a plain batch CSV export, a store-credit
  wallet and bank transfer. Affiliate-chosen payout methods and withdrawal
  requests. The PayPal Payouts API, Stripe Connect, Wise bulk-payment files and
  the provider-shaped CSV exports are Squad Affiliate Pro.
* Divi 5 modules: Affiliate Registration Form and Affiliate Dashboard, plus
  shortcodes for the portal, its individual screens and referrer-aware landing
  pages.
* Affiliate-initiated direct-link requests: an affiliate asks that their own
  domain be credited to them, and you approve or decline it from the same
  Direct links screen used to register one directly. A request changes nothing
  on its own — only your approval creates the live claim.
* Twenty-one REST controllers under `squad-affiliate/v1`, outbound webhooks, and a
  registered Abilities API surface with an MCP server over it.
* Editable transactional emails with preview and test send; a monthly summary.
* Setup wizard, sample-data importer, and one-click migration from eighteen
  competitor plugins plus CSV.
* GDPR personal-data exporter and eraser, with IP-retention control.
* Fail-open risk seam: no scorer ships in Lite, and an absent verdict is a
  neutral approve marked degraded.

== Upgrade Notice ==

= 1.0.0 =
First release.
