No user can visit wp-admin

Message

Sorry, you are not allowed to access this page.

WP Core

Check user first:

wp-cli  user list
+----+------------+--------------+--------------------+---------------------+-------+
| ID | user_login | display_name | user_email         | user_registered     | roles |
+----+------------+--------------+--------------------+---------------------+-------+
| 1  | the-admin | the-admin   | admin@admin.com | 2023-10-22 20:23:02 |       |
+----+------------+--------------+--------------------+---------------------+-------+

Note that NO role is present.

Now check the DB user table:

Now list all existing site roles ( https://developer.wordpress.org/cli/commands/role/list/ )

wp-cli role list
+------+------+
| name | role |
+------+------+
+------+------+

Note that the whole site does not have roles.

Now add the base roles again ( https://developer.wordpress.org/cli/commands/role/ )

wp-cli role reset administrator author contributor editor subscriber
Restored 61 capabilities to and removed 0 capabilities from 'administrator' role.
Restored 10 capabilities to and removed 0 capabilities from 'author' role.
Restored 5 capabilities to and removed 0 capabilities from 'contributor' role.
Restored 34 capabilities to and removed 0 capabilities from 'editor' role.
Restored 2 capabilities to and removed 0 capabilities from 'subscriber' role.
Success: 5 of 5 roles reset.

Leave a Comment