Create Custom Commands

Apart from the default commands, you can also create your own custom WP-CLI commands. That’s the level of flexibility it offers. Also, there’s no limit to what you can do with WP-CLI when you are managing your website from the command line.

Refer the below video for a detailed example of how to add a custom command.

For more information on how to create custom WP-CLI commands, have a look at the Commands Cookbook. There are multiple ways to create custom commands.

Ideas to Explore:

  • Write a WP-CLI command to add two capabilities( read, edit_posts ) to a custom role name ‘Approver’.
  • How do you debug a WordPress plugin that’s causing a fatal error, but you can’t access the WordPress admin dashboard?
  • How can you use WP CLI to:
    • create a new user rtDummy with subscriber role and password = 1234
    • update the user’s role to administrator