One possibility is that the user roles and capabilities on your WordPress site have been manipulated incorrectly, possibly by a plugin or custom code.
If your error log is still indicating that the problem is in the class-wp-roles.php
file after trying all the steps you’ve mentioned, it could be an issue in your database, specifically within the wp_options
table. The wp_user_roles
row in the wp_options
table might have been corrupted. This row contains all the user role definitions.
Before proceeding, please make sure to back up your database. You can then try to repair the database. If you have phpMyAdmin in your hosting control panel, you can use it to repair the database.
If that doesn’t work, you may need to reset your user roles. There are plugins like “User Role Editor” that can reset your roles to their WordPress defaults, but since you can’t access the dashboard, you might need to use WP-CLI (if your host provides it) or do it manually.
To do it manually, you’d need to access your database (likely through phpMyAdmin) and find the wp_options
table, then the wp_user_roles
row. The default value of this row for a fresh WordPress install can be found in the wp-includes/class-wp-role.php
file. You can replace the corrupted value with the default value from a fresh WordPress install.
Keep in mind this advice assumes the database is the issue, it’s possible that the issue is still elsewhere.