Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tanftw/04fe3721c3d96d8b4ab3e1d4b3b1fd89 to your computer and use it in GitHub Desktop.
Save tanftw/04fe3721c3d96d8b4ab3e1d4b3b1fd89 to your computer and use it in GitHub Desktop.
Sorry, you are not allowed to access this page WordPress error

Yesterday, I installed WordPress on Windows/XAMPP. I rarely use native Windows for developing PHP projects, but recently, I have to use some Windows app during development so I install XAMPP for quick up and running because WSL2 isn't stable yet.

Everything works well, until I access wp-admin, I immediately got a big error message that I never met in Linux:

"Sorry, you are not allowed to access this page"

I always turn on debug and error reporting, so this message obviously doesn't help me anything. I've checked rewrite rules, log files, .htaccess, wp-config.php but this doesn't help. I got frustrated.

Checking these things doesn't helps, WP seems doesn't provide any useful message. I've checked the database, my table prefix is exactly same as wp-config file. My frontend works fine, until I logged in as admin, so I think the problem is the user permissions. But why?

Problems

I have checked the wp_usermeta but didn't noticed that they use table prefix for their meta field, and you know what? MySQL have a config that makes table names always lowercase. That was enabled by default in XAMPP.

lower_case_table_names = 1

Our database table names was lowercased but meta data weren't, so the code can't check for right permissions. I blame WP for that. It isn't necessary to put table prefix in meta key. That makes things harder, even when we need to change table prefix also.

Solution

I change the table prefix to match case with meta data and everything works fine. For future, please always use lowercase for table prefix in WordPress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment