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 |
| 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?
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 |
| 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
Reset to default 8By 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.