Version 1.6 of Download Protect includes WP CLI integration as experimental. It will not be considered a “full feature” until version 2.0. Until that point, commands and options are 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 dp --help or
wp dp <command> --help
The Download Protect CLI commands can be used as their own command set (
wp dp), OR, when using WP-Members 3.3.5 or higher, it is available as a sub command of the WP-Members CLI:
wp mem dp.
This command “Lists” the requested item. This can be a list of files currently in Download Protect or allowed mime types.
wp dp list files – or –
wp mem dp list files Lists all files currently in Download Protect.
wp dp list mime_types – or –
wp mem dp list mime_types Lists all mime types that can be moved by Download Protect.
The “move” command is used to move files from regular WP Media attachments to the Download Protect folder while maintaining their attachment post type data intact (i.e. the same post ID). Use this command to handle bulk moves of existing files without having to reupload each file.
wp dp move --all or
wp mem dp move --all Moves ALL files of allowed file mime types (see “list” command above). Note: NO image files will be moved.
wp dp move --type=<file mime type> or
wp mem dp move --type=<file mime type> Moves all files of a specified mime type (such as “application/pdf”). If you are not sure of the exact mime type of a specific file extension, use the “list” command to get mime types (see “list” command above).
The “move” command has a “dry run” option that will list what it will do for your command set without actually doing the move or updating anything. Just add the
--dry-run option to your command. For example,
wp dp move --all --dry-run
The “rename” command can be used to rename a file. You must specify the file by its ID (you can find this either in the WP admin, the database, or use the “list” command to get files in Download Protect which also displays the attachment ID). You also must specify the new title using the
--title= option. If the title has spaces, wrap it in quotes.
wp dp rename --id=123 --title=Title
wp dp rename --id=321 --title="Title with White Space"
The delete command can be used to delete a single file in Download Protect, or all files. Note: this only affects files in Download Protect – not files in the general Media Manager.
--id option to specify a file ID to delete, or use
--all to specify all files.
The command includes a confirmation message, but it is important to note that this deletes the file attachment data in the WP database, and also deletes the physical file. It cannot be undone.
wp dp delete --id=123
wp dp delete --all