Version 2.1 of MailChimp Integration includes WP CLI integration. Keep in mind that as a new feature, commands and options may still be subject to change. There may be minor changes from version to version so if a previous command you were using ceases to work, check here for the official current command documentation (also available as
wp mc --help or
wp mc <command> --help
The MailChimp CLI commands can be used as their own command set (
wp mc), OR, when using WP-Members 3.3.5 or higher, it is available as a sub command of the WP-Members CLI:
wp mem mc.
This command “gets” the requested information.
Get all users with the “get all” command:
wp mem mc get all or
wp mc get all Gets all users and their subscribe info on both the local site and MailChimp.
--subs to get all unsubscribed or subscribed users. You can get this information by users on the local site or users in the MailChimp list by adding “local” or “mc”/”mailchimp”. For example
wp mem mc get --unsubs=local would get all users unsubscribed on the local site.
wp mem mc get --subs=mc would get all users subscribed on the MailChimp side of things. Subscriptions should be kept in sync with webhooks, but this tool can be used to audit your site information for users who are mismatched.
get can also be used to get information on an individual list member. Specify the user by email address:
wp mem mc get firstname.lastname@example.org would get information from MailChimp on this user. You can also use the following attributes for additional user information:
wp mem mc get email@example.com --location
wp mem mc get firstname.lastname@example.org --merge_fields
wp mem mc get email@example.com --interests
Subscribe / Unsubscribe
The subscribe and unsubscribe commands can be used to subscribe or unsubscribe a user from your list.
wp mem mc subscribe firstname.lastname@example.org would subscribe the user to your list.
This command gets the subscription status of a requested user. You can get a user by WP ID or by email address. The command tells you the subscribe status on both the local site and MailChimp.
wp mem mc status email@example.com returns the subscribe status of this user.
This command has several subcommands to manage batch operations (bulk synchronization of users). It is only available in version 2.1.1 and higher (currently in development).
subscribe– runs a batch operation that adds all users to Mailchimp as subscribed. Users already in Mailchimp are skipped.
sync– runs a batch operation that adds users to Mailchimp. If the user already exists in Mailchimp, they will be updated with data from any mapped merge fields and interests. (Users are only subscribed if new. Existing users keep their status setting.)
status– returns status information for the most recent batch or a requested batch (by batch ID).
results_url– returns the URL of Mailchimp’s batch results for the most recent id (default) or requested id.
last_id– returns the most recent batch ID.
clear– clears the batch results information.
status default to the most recent batch ID but accept additional arguments. Both accept
--id=<batch id> for information regarding a requested batch ID (if it exists in the saved settings, which can be cleared using
wp mem mc clear.
status also accepts a
--view-all parameter to show all batches in the saved results.
wp mem mc batch subscribe will begin a batch to add users to Mailchimp. Users already in Mailchimp are skipped. Users are added as subscribed.
wp mem mc batch sync will begin a batch to sync users in the site to Mailchimp. New users will be added as subscribed, users already in Mailchimp will be updated. Merge fields and interests that are mapped will be included. Subscribe status is only updated for new users (added as subscribed).
wp mem mc batch last_id will provide you the most recent batch ID that has been run.
wp mem mc batch status will provide you the status of the most recent batch ID.
wp mem mc batch status --id=<batch id> will return the status of the requested batch ID.
When the batch status is “finished”, you can retrieve a JSON file of results from a URL Mailchimp provides.
wp mem mc batch results_url returns the URL of the most recent batch. Add
--id=<batch id> for a specific batch ID. These URLs expire, so the data is not stored indefinitely.
wp mem mc batch clear will clear all stored batch results.