WordPress Admin Dashboard Access Issue

Overview

A WordPress website allowed users to log in successfully through wp-login.php, but no administrator account could access the WordPress dashboard (wp-admin). The issue affected both existing admin users and newly created administrator accounts.


Problem

  • Login page worked correctly.
  • Administrator users could authenticate successfully.
  • Access to /wp-admin failed after login.
  • Creating a new administrator user directly in the database did not solve the issue.

Troubleshooting Steps

1. Replaced WordPress Core Files

Replaced all WordPress core files with a fresh copy while keeping:

  • wp-content
  • wp-config.php

2. Disabled All Plugins

Temporarily disabled all plugins by renaming the plugins folder.

wp-content/plugins
→
wp-content/plugins_disabled

3. Cleaned Configuration Files

Verified and cleaned:

  • .htaccess
  • wp-config.php

4. Switched to a Default Theme

Changed the active theme directly from the database.

UPDATE wp_options
SET option_value = 'twentytwentyfive'
WHERE option_name IN ('template','stylesheet');

5. Checked WordPress Roles

Verified the stored user roles.

SELECT option_name, option_value
FROM wp_options
WHERE option_name = 'wp_user_roles';

Only custom SEO roles were present, while the default WordPress roles (Administrator, Editor, Author, Contributor, and Subscriber) were missing.


Root Cause

The default WordPress user roles had been removed from the database. As a result, administrator accounts could log in but did not have the required capabilities to access the dashboard.


Solution

Created a temporary MU Plugin to regenerate the default WordPress roles using WordPress’ built-in function.

File

wp-content/mu-plugins/fix-roles.php

Code

<?php
require_once ABSPATH . 'wp-admin/includes/schema.php';
populate_roles();

After creating the file:

  1. Visited any page on the website once.
  2. Deleted the MU plugin immediately after the roles were regenerated.

The administrator dashboard became accessible again without reinstalling WordPress or modifying user accounts.


Tools Used

  • WordPress
  • phpMyAdmin
  • SQL
  • MU Plugin
  • AI Assistant (for troubleshooting)

Result

  • Successfully restored the missing WordPress roles.
  • Existing administrator accounts regained dashboard access.
  • No data loss or WordPress reinstallation was required.

Skills Demonstrated

  • WordPress Troubleshooting
  • Database Analysis
  • SQL
  • WordPress User Roles & Capabilities
  • MU Plugin Development
  • AI-Assisted Problem Solving