I've written a command for wp-cli called wp nurse. It is styled after the wp doctor command, except is meant to run the WordPress Site Health checks. Using the in-browser tool, all 16 tests currently pass. However, when calling it from wp, only 13 of the tests are succeeding.

ichabod:~ uplime% wp nurse check --all
| name                 | status      | message                                                |
| wordpress_version    | good        | Your version of WordPress (5.3) is up to date          |
| plugin_version       | good        | Your plugins are all up to date                        |
| theme_version        | good        | Your themes are all up to date                         |
| php_version          | good        | Your version of PHP (7.3.12) is up to date             |
| sql_server           | good        | SQL server is up to date                               |
| php_extensions       | good        | Required and recommended modules are installed         |
| utf8mb4_support      | good        | UTF8MB4 is supported                                   |
| https_status         | good        | Your website is using an active HTTPS connection.      |
| ssl_support          | good        | Your site can communicate securely with other services |
| scheduled_events     | good        | Scheduled events are running                           |
| http_requests        | good        | HTTP requests seem to be working as expected           |
| debug_enabled        | good        | Your site is not set to output debug information       |
| rest_availability    | recommended | The REST API encountered an unexpected result          |
| dotorg_communication | good        | Can communicate with WordPress.org                     |
| background_updates   | critical    | Background updates are not working as expected         |
| loopback_requests    | recommended | Your site could not complete a loopback request        |
Error: Only 13/16 tests passed

Digging through the code for these tests, it looks like they're failing due to not being authenticated (rest_availability, background_updates, and loopback_requests). For example, background_updates looks to call out to GET /wp-admin/site-health.php?health-check-test-wp_version_check=1, which fails, since I'm not technically signed into the dashboard. Short of creating a temporary administrator, and signing in with that (which sounds like a bad workaround), is there any way to authenticate with WordPress temporarily, so that these tests can pass?

1 Answer 1


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.


      Set the WordPress user.
  • Thanks! Do I need to add any code afterwards to actually use that user? Those tests still seem to fail after running wp nurse check --all --user=1 (I've removed the user creation code I was experimenting with) Commented Dec 11, 2019 at 7:59
  • @LuckyTheRabbit – You said you took wp doctor for an example. You need to look how doctor is making use of that user parameter and rebuild the same. Basically, I'd say you need to pick up this option and load the user in your code somehow.
    – leymannx
    Commented Dec 11, 2019 at 8:04
  • Ah, fair point. I'll study that some more then. Appreciate the insight! Commented Dec 11, 2019 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.