How can I run a WP-CLI command as authenticated user?

By default WP-CLI executes every command as unauthenticated (logged-out) user. To execute a command as any existing WordPress user you can use the global --user parameter, which accepts an user ID, login, or email address.

$ wp nurse check --all --user=1

You’ll get all other global parameters listed when running $ wp --help or $ wp COMMAND --help.

GLOBAL PARAMETERS

  --user=<id|login|email>
      Set the WordPress user.

Leave a Comment