WP-CLI - Overview

AffiliateWP 1.9 and later offers a variety of WP-CLI commands for managing affiliate, creative, payout, referral, visit, and system data from the command-line on the fly.

Getting Started

WP-CLI command support in AffiliateWP is broken up into two main groups:

  1. System commands, executed via wp affwp <command>
  2. Object commands, executed via wp affwp [object] <command>.

To list all system and object command groups, execute wp help affwp. It will output documentation similar to this:


System-level Commands

System-level commands can be accessed via the top-level command namespace, wp affwp. They include:

  • wp affwp details
    Prints out main AffiliateWP configuration details, including the AffiliateWP version, license status, active integrations, key settings, and more.
    – Execute wp help affwp details to find out more.
  • wp affwp stats
    Prints out the total number of affiliates, creatives, payouts, referrals, and visits for the current site. An optional --global parameter pulls global stats for every site in a multisite network.
    – Execute wp help affwp stats to find out more.
  • wp affwp debug
    Prints out the contents of the affwp-debug.log file generated when Debug Mode is enabled in the AffiliateWP settings. An optional --clear parameter makes clearing the debug log a snap.
    – Execute wp help affwp debug to find out more.
  • wp affwp info
    Similar to the wp affwp details and wp affwp debug commands, this command prints out the contents of the System Info log used primarily for troubleshooting purposes when you contact support.
    – Execute wp help affwp info to find out more.

Object-level Commands

Object-level WP-CLI commands allow for robust management of affiliates, creatives, payouts, referrals, and visits from the command line. Sub-commands are grouped by object, accessed via wp affwp [object] <command>. They include:

  • wp affwp affiliate <command>
    Commands: create, delete, get, list, update
    Documentation
  • wp affwp creative <command>
    Commands: create, delete, get, list, update
    Documentation
  • wp affwp payout <command>
    Commands: create, delete, get, list, update
    Documentation
  • wp affwp referral <command>
    Commands: create, delete, get, list, update
    Documentation
  • wp affwp visit <command>
    Commands: create, delete, get, list, update
    Documentation

Click the links in the list above to navigate to pages containing much more comprehensive documentation on accepted options and available sub-commands. 


Additional Help

To preview help documentation for any core- or system-level commands, try prefixing the command chain with help. For instance:

wp help affwp stats

The above will output the help page for the wp affwp stats command. Like so: