Lost WordPress Admin Access? Fix the wp_user_level Error Fast

WordPress admin access lost
💡 When you purchase through links on our site, we may earn a small commission at no extra cost to you. Learn more.

Last Updated on August 3, 2025 by Team Digital Web Verse


So there I was — sipping my chai and getting ready to tweak a few things on one of my WordPress blogs — when boom, I got slapped with this dreaded message:

“Sorry, you are not allowed to access this page.”

How to Fix wp_user_level Error and Restore WordPress Admin Access

Logged in. No dashboard. No sidebar. Nothing.

Just a white screen and that single line mocking me.

It felt like one of those classic WordPress admin access lost situations, and I’ll be honest — for a moment, I thought I got hacked. Or maybe some plugin update just nuked my admin privileges. Either way, if you’re reading this, you’re probably staring at that same annoying message and wondering, “What now?”

Good news? I figured it out. And I’m going to walk you through how I fixed it — step-by-step — without losing my mind (or my site).


What Causes the “WordPress Admin Access Lost” Problem?

You’d be surprised at how fragile WordPress can be sometimes. One tiny thing breaks, and suddenly you’re locked out of your own house.

Here are some common reasons you’ll see the “WordPress sorry you are not allowed to access this page” error:

  • Broken or missing wp_capabilities: One of the most common reasons behind the WordPress admin access lost error is a corrupted or missing wp_capabilities entry in your database. This is a critical field in your WordPress database that tells the system what your user can and can’t do. If it’s missing or corrupted, your role could disappear.
  • Plugin conflicts: Especially with AI tools, caching plugins, or anything that touches user roles.
  • Database glitches or theme bugs: I once had a theme update reset some permissions without warning. Not fun.
  • Manual edits gone wrong: Maybe you tweaked a user role or imported a database. Stuff happens.

But the good news? We can fix this. Let’s dive in.


Step-by-Step Fix for WordPress Admin Access Lost

Method 1: Check and Update Database

If you’ve hit the WordPress admin access lost wall, phpMyAdmin is your best friend. This is where you’ll dig into the database and bring your access back.

1. Log in to phpMyAdmin via cPanel

First things first — you’ll need to access your database using phpMyAdmin (official guide) through your hosting panel.

  • Log in to your hosting control panel (e.g., cPanel — e.g, on HostGator, they make it super simple).
  • Scroll down to the Databases section and open phpMyAdmin.
  • On the left side, click your WordPress database (it might be named something like wp1234_db).

If you’re not sure which database your site is using, check your wp-config.php file in the root folder via File Manager or FTP.


2. Find the usermeta Table

Inside the database, look for a table called something like wp_usermeta or wpep_usermeta (Prefixes can vary.)

Once inside:

  • Search for rows where the user_id matches your admin ID.
  • Look for these two meta_key values:
    • wp_capabilities
    • wp_user_level

If they’re missing, empty, or duplicated — bingo, that’s likely your problem.

Here’s how to fix them.


3. Set wp_capabilities and wp_user_level

Let’s manually add the correct values. If they exist but are wrong, just update them.

SQL to insert/replace:

REPLACE INTO `wp_usermeta` (user_id, meta_key, meta_value)
VALUES
(1, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}'),
(1, 'wp_user_level', '10');

⚠️ Replace 1 with your actual admin user ID, and wp_ with your table prefix.

What this does:
  • wp_capabilities tells WordPress that your user has admin privileges.
  • wp_user_level ensures your access level is set to 10 (admin).

Make sure you don’t have duplicate entries for the same meta_key. If you do…


4. Clean Up Duplicates

Sometimes, WordPress glitches or migrations leave behind duplicate entries. That messes with role recognition.

Here’s what I did:

  • Filter the usermeta table by user_id = YOUR_ID and check for multiple wp_capabilities or wp_user_level entries.
  • Delete the extras — just keep one of each with the correct values above.

Always take a backup before making changes. Better safe than sorry.


Method 2: Use the functions.php Trick

If the database route doesn’t solve your WordPress admin access lost situation, this simple functions.php trick might do the trick.

  1. Go to your theme folder via File Manager or FTP.
  2. Edit the active theme’s functions.php file.
  3. Add this snippet at the bottom:
function restore_admin_access(){
$user = get_user_by('login', 'yourusername');
$user->set_role('administrator');
}
add_action('init', 'restore_admin_access');

Replace 'yourusername' with your actual WordPress login name.

This bit of code:

  • Finds your user
  • Assigns the administrator role back to you

Once you’ve logged in successfully and everything’s back to normal, remove this code. Leaving it there can be a security risk. This guide explains how WordPress handles permissions behind the scenes.


Method 3: Disable Plugins from File Manager

Sometimes the problem isn’t with roles at all — it’s a plugin going rogue.

Here’s a quick fix:

  • Go to wp-content/ via File Manager.
  • Rename the plugins folder to plugins_old.

That will deactivate all plugins at once. Try logging in again.

Once you’re in:

  • Rename the folder back to plugins
  • Reactivate plugins one by one to spot the troublemaker

I once found that a fancy AI writing plugin was completely messing with my admin area. Lesson learned.

💡 You might also find these helpful:

Dealing with WordPress issues? Here are a few related guides that’ll save your time and sanity:

👉 WordPress Blog Setup: Step-by-Step for Beginners
👉 12 Best WordPress Themes for Bloggers: Free & Paid
👉 Web Hosting Comparison: Best Picks for New Bloggers


Bonus Fix: Can’t Edit Older Posts Even Though You’re Admin?

So, here’s a fun curveball that happened to me right after I got back admin access — I could create new posts no problem, but editing my older posts? Nope. WordPress just wouldn’t let me. This is actually a sneaky symptom of the bigger WordPress admin access lost issue — your role may look like an admin, but WordPress doesn’t think so.

If that sounds like your situation, you’re probably facing a partial permissions problem. Your user role might say “Administrator,” but some important editing capabilities are missing behind the scenes.

Here’s a quick way to fix it:

Add this snippet to your theme’s functions.php file temporarily:

function rebuild_admin_capabilities() {
$role = get_role( 'administrator' );
if ( ! $role ) {
add_role( 'administrator', 'Administrator' );
$role = get_role( 'administrator' );
}

$caps = array(
'edit_posts',
'edit_others_posts',
'edit_published_posts',
'publish_posts',
'delete_posts',
'delete_others_posts',
'delete_published_posts',
'manage_options',
'edit_pages',
'edit_others_pages',
'edit_published_pages',
'delete_pages',
'delete_others_pages',
'delete_published_pages',
'publish_pages',
'read',
'upload_files',
);

foreach ( $caps as $cap ) {
$role->add_cap( $cap );
}
}
add_action( 'init', 'rebuild_admin_capabilities' );

This code will make sure your admin role has all the editing powers it’s supposed to have, including editing older posts.

Once you’re back in full control, remove the snippet to keep things tidy and secure.

Here’s another take if you want to cross-check a few things – WPBeginner has a great walkthrough on this issue if you want another angle.


FAQs

What causes the “WordPress, sorry you are not allowed to access this page” error?

It’s usually due to a broken user role or corrupted database entries, particularly wp_capabilities. Sometimes, plugins or themes mess things up, too.

How can I restore administrator access in WordPress?

Use phpMyAdmin to manually set the correct wp_capabilities and wp_user_level. Or, temporarily use the functions.php method to reset your role.

Is it safe to edit the WordPress database directly?

It’s safe if you know what you’re doing and you back up beforehand. Small edits like setting user roles are common fixes.

Can a plugin cause admin access to break?

Absolutely. Poorly coded plugins, especially ones dealing with security or user roles, can cause access issues.

What if I have no idea what my user ID is?

You can find it in the wp_users table. Each user has an ID associated with their username and email.

Final Thoughts: Don’t Skip Backups & Be Cautious

If there’s one thing I took away from this headache, it’s the importance of backups.

I now use UpdraftPlus on all my blogs to automate daily backups to Google Drive. Trust me, when stuff hits the fan, backups feel like magic.

Also:

  • Avoid bulk installing plugins just because a YouTube video said they’re “must-haves.”
  • Always update themes and plugins with caution, especially from unknown sources.

Oh, and one more thing — if you’re still in the setup phase of your blog, this is a great reminder to get everything configured the right way from the start. Check out my full guide on WordPress Blog Setup if you’re starting fresh.

Hopefully, this guide saved you hours of stress and Google searches. If you’re still struggling, consider checking with your host’s support — HostGator, Bluehost, or NameCheap all have decent support teams that can help with basic fixes.

Stay calm, take backups, and don’t panic next time WordPress throws a tantrum. You got this.

Up Next:

Need help picking your theme, setting up hosting, or staying on track?
Grab our free Beginner Blogger Checklist — includes blog setup steps, SEO prep, monetization pointers, and more.

Or, if you’re ready to dive in:

👉 How to Start a Blog
👉 Perfect Blog Name Ideas
👉 Blog Niche Ideas for 2025
👉 Google Analytics + Search Console Setup


Scroll to Top