WordPress后台登录提示‘Sorry, you are not allowed to access this page.’问题求助
Hey there, sorry to hear you're hitting that frustrating "Sorry, you are not allowed to access this page." error when trying to get into your WordPress dashboard. Since disabling all plugins didn't fix it, let's walk through some other common fixes that usually resolve this issue:
1. Double-Check Your User Role Permissions
It's possible your user role got accidentally changed (maybe from a botched update or a misconfig somewhere). Here's how to confirm and fix it:
- Log into your hosting control panel and open phpMyAdmin (most hosts have this under "Databases").
- Find your WordPress database, then open the
wp_userstable. Locate your user entry and note down yourIDnumber. - Next, open the
wp_usermetatable. Search for rows whereuser_idmatches your ID andmeta_keyiswp_capabilities(if your database uses a different prefix thanwp_, use that instead). - Look at the
meta_valuefield—if you're supposed to be an admin, it should haveadministratorlisted. If not, edit the value to:a:1:{s:13:"administrator";b:1;} - Save the change, then try logging into the dashboard again.
2. Switch to a Default WordPress Theme
Custom themes can sometimes mess up permission checks, even with plugins disabled. Here's how to test this:
- Use FTP or your hosting file manager to go to
/wp-content/themes/. - Rename your active theme's folder (add
-oldto the end, likemy-custom-theme-old). WordPress will automatically fall back to a default theme like Twenty Twenty-Four. - Try accessing the dashboard again. If it works, your theme was the problem—you can either troubleshoot the theme code or switch to a new one.
3. Reset Your .htaccess File
A corrupted .htaccess file is a common culprit for access issues. Let's fix that:
- In your site's root directory (where wp-config.php lives), find the
.htaccessfile. - Rename it to
.htaccess-oldto disable it temporarily. - If you can log in, go to Settings > Permalinks and click "Save Changes"—this generates a fresh, properly configured .htaccess file automatically.
- If you can't log in to save permalinks, manually create a new
.htaccessfile with this default content:# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress - Test accessing the dashboard again.
4. Check wp-config.php for Restrictive Settings
Sometimes lines in wp-config.php can block admin access without you realizing it:
- Open wp-config.php via FTP or file manager.
- Look for lines like
define('DISALLOW_FILE_EDIT', true);—that's normal for security, but if you see something likedefine('ADMIN_COOKIE_PATH', '/wrong-path/')or other odd restrictive defines, comment them out by adding//at the start (e.g.,// define('ADMIN_COOKIE_PATH', '/wrong-path/')). - Save the file and try logging in again.
5. Fix Incorrect File Permissions
Wrong file permissions can prevent WordPress from accessing the files it needs for the dashboard. Stick to these safe settings:
- Directories: Set permissions to 755
- Files: Set permissions to 644
- wp-config.php: Set to 600 (extra secure, prevents unauthorized access)
- Most FTP clients let you set permissions recursively, but never set everything to 777—it's a huge security risk.
If none of these work, try reuploading the core WordPress files (excluding wp-content and wp-config.php). Download the latest WordPress version, extract it, then upload the wp-admin and wp-includes folders via FTP, overwriting the existing ones. This replaces any corrupted core files that might be causing the issue.
内容的提问来源于stack exchange,提问作者shubham shah

