AFI AFI

AffiliateWP

Estimated reading: 4 minutes Updated August 1, 2026

AffiliateWP is a WordPress affiliate marketing plugin. Advanced Form Integration creates affiliates and referrals directly in AffiliateWP from your WordPress form submissions, so sign-up forms can auto-register affiliates and external systems can log referrals without manual entry.

What you’ll need

  • The AffiliateWP plugin installed and activated.
  • The Advanced Form Integration plugin installed and activated.

AffiliateWP runs on the same WordPress installation as AFI, so there is no API key or external connection to set up. AFI calls AffiliateWP’s PHP functions (affwp_add_affiliate() and affwp_add_referral()) directly.

Create the integration

  1. Go to AFI → Add New.
  2. Give the integration a name, for example Registration form to AffiliateWP.
  3. Under Trigger, pick the form plugin and the specific form you want to listen on.
  4. Under Action → Platform, select AffiliateWP.
  5. In Task, choose Create Affiliate or Create Referral.
  6. Map your form fields onto the AffiliateWP fields listed below.
  7. Optional: open Conditional Logic to limit which submissions are sent.
  8. Click Save Integration.

Tasks supported

Create Affiliate

Creates a new affiliate via affwp_add_affiliate(). You must provide either an existing WordPress User ID or a User Email so AffiliateWP can locate (or create) the linked user. The affiliate appears in your AffiliateWP dashboard immediately.

Field Field key Required Notes
User ID user_id One of user_id / user_email Existing WordPress user ID
User Email user_email One of user_id / user_email AffiliateWP will look up or create the user by email
User Name user_name No Username for new user creation
Status status No active (default) or pending for manual approval
Rate rate No Commission rate (overrides global default)
Rate Type rate_type No percentage or flat
Flat Rate Basis flat_rate_basis No per_affiliate or per_referral
Payment Email payment_email No Email for payout services (may differ from login email)
Website URL website_url No
Notes notes No Internal notes
Dynamic Coupon dynamic_coupon No Boolean: generate a dynamic coupon for this affiliate
Registration Method registration_method No
Registration URL registration_url No

Create Referral

Creates a referral via affwp_add_referral(). You must identify the affiliate by providing at least one of: Affiliate ID, User ID, or Username. The referral appears in the AffiliateWP referrals screen linked to the matched affiliate.

Field Field key Required Notes
Affiliate ID affiliate_id One of affiliate_id / user_id / user_name Numeric AffiliateWP affiliate ID
User ID user_id One of affiliate_id / user_id / user_name WordPress user ID linked to the affiliate
Username user_name One of affiliate_id / user_id / user_name WordPress username
Amount amount No Referral commission amount
Description description No
Reference reference No Order or transaction reference
Order Total order_total No Full order amount (used for percentage calculations)
Currency currency No
Campaign campaign No
Context context No Integration source (e.g. woocommerce)
Status status No pending, accepted, rejected, or paid
Custom custom No JSON or serialized data
Products products No JSON array of product data
Parent ID parent_id No Parent referral ID for sub-referrals
Visit ID visit_id No Linked visit ID

Conditional logic example

Only create affiliates when the form’s agree_terms checkbox is checked, so submissions without consent do not create affiliate accounts. Add a condition: Agree to Terms is Yes.

Troubleshooting

“AffiliateWP plugin is not active”

AFI calls affwp_add_affiliate() and affwp_add_referral() directly. If AffiliateWP is deactivated or the functions are not available, AFI logs the error and skips the request. Verify AffiliateWP is activated on the same WordPress installation.

Affiliate not created

Affiliate creation requires either a User ID or User Email. If both are empty, the request fails and the error is logged. If you pass a user email for a non-existent user, AffiliateWP can create the user automatically if a username is also provided.

Referral not created

Referral creation requires at least one of: Affiliate ID, User ID, or Username. If the affiliate cannot be located, the referral is not created. Check the AFI log for the specific error message.

Nothing appears in the log

If there is no log entry at all, the trigger never fired. Submit a real test entry from the front end (not the form builder preview) and check that the integration’s trigger matches the correct form.

Related docs