Closed envue closed 7 years ago
This plugin piggybacks on the functionality of the CSV importer that's built into WooCommerce Memberships. When Memberships is loading itself, it checks to see whether the WordPress frontend or admin is being displayed and only loads the necessary parts of itself. Because we need the CSV importer to load, and because it is loaded only when the admin is being displayed, WordPress and Memberships need to behave as if they're loading in an admin environment. Luckily, WordPress promises to behave this way if the WP_ADMIN
constant is set to true
.
I've included a file in the repo (includes/define-wp_admin-true.php
) that can be used with WP-CLI's --require
flag in order to set the WP_ADMIN
constant to true
as WP-CLI loads.
Make sure you use the included file with a --require
flag like so:
# Use a user with suitable permissions
# Load a file on startup that defines WP_ADMIN as true
# Make sure you use the correct path to reach the required file; this one is just an example
$ wp wc memberships import file.csv --user=wp.admin@example.com --require=define-wp_admin-true.php
I'm not a developer so forgive me if I'm doing something stupid, however when I run the import command I get the error "this command must be run within the context of the Wordpress administration screens. In order to do so use wp-cli's command line parameter --require to include a file that defines the wp-admin constant as true"