[FIX] "Sorry, You Are Not Allowed to Access This Page" in WordPress (SQL Solution!)

Опубликовано: 28 Апрель 2026
на канале: FauL UppU
152
2

🚀 Fix "Sorry, You Are Not Allowed to Access This Page" in WordPress Using SQL!

If you're locked out of your WordPress admin panel and see the error "Sorry, you are not allowed to access this page," don’t worry! In this tutorial, I’ll show you how to manually check and assign the Administrator role using SQL.

This method works if:
✅ You lost admin access to your WordPress site
✅ A plugin or theme update removed your permissions
✅ You're restoring admin access manually via phpMyAdmin

🔧 Step-by-Step Guide (With SQL Commands)
📌 Step 1: Open phpMyAdmin & Select Database
1️⃣ Log into phpMyAdmin (or any database tool like MySQL Workbench).
2️⃣ Select your WordPress database from the left panel.

📌 Step 2: Check If the User Exists
Run this SQL query to confirm that the user exists:

SELECT ID, user_login FROM wp_users WHERE user_login = 'USERNAME';

🔹 Replace 'USERNAME' with your actual WordPress username.
✅ If a result appears, note the ID number (e.g., 3).
❌ If no result appears, the user does not exist—you may need to create one manually.

📌 Step 3: Check If the User Has Any Role Assigned
Run this SQL command to see if the user has any assigned roles:

SELECT meta_value FROM wp_usermeta WHERE user_id = USER_ID AND meta_key = 'wp_capabilities';

🔹 Replace USER_ID with the actual ID from Step 2.

Understanding the Output:
✅ If you see something like this:

a:1:{s:13:"administrator";b:1;}

➡ The user already has admin access. Try clearing your cache or checking for plugin conflicts.

❌ If no rows appear, the user has no role assigned—proceed to the next step.

📌 Step 4: Assign the Administrator Role
If the role is missing, manually add it with this SQL command:

INSERT INTO wp_usermeta (user_id, meta_key, meta_value)
VALUES (USER_ID, 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');

🔹 Replace USER_ID with the actual user ID.

✅ This assigns the Administrator role to the user.

📌 Step 5: Verify the Changes
Run the following command to confirm the role was updated:

SELECT meta_value FROM wp_usermeta WHERE user_id = USER_ID AND meta_key = 'wp_capabilities';

✅ If the output contains "administrator", the user has admin rights!

📌 Step 6: Log Back Into WordPress
1️⃣ Open your WordPress login page:

https://yourwebsite.com/wp-admin

2️⃣ Enter your username and password.
3️⃣ If everything worked, you should now have admin access again! 🎉