More fixes

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

The password works and the login goes through, then the dashboard, or one page of it, answers "Sorry, you are not allowed to access this page." WordPress knows who you are but no longer believes you are an administrator. Where the message appears tells you why: on every admin page it is almost always a database detail left behind by a host move or a security tweak; on one page only it is usually a plugin page that no longer exists. Below is a rebuilt example (not a real client), then how to tell the cases apart and the fix for each.

What the owner sees after logging in

brightloafbakery.example/wp-admin/

What the checks found


  

Which case is yours (two minutes)

  1. Open /wp-admin/ itself, not a bookmark. If the dashboard loads and only a saved link fails, skip to fix 3: that page belonged to a plugin that is switched off, removed or renamed.
  2. If every admin page refuses you, think back: a host move, a "change the table prefix" security tip, a restore from backup, or a user-role plugin. Any of those can leave WordPress unable to read your role.
  3. Check whether the front of the site still works. If visitors see the site normally, your content is safe; this is only about your account's role.
  4. Look at the error wording. "Sorry, you are not allowed to install plugins on this site" or "...to edit templates" is a different, deliberate lock: see fix 4.

The fixes

  1. The table prefix changed (most common after a move). WordPress stores your role in the database under names that start with the table prefix, for example wp_capabilities. If the tables were renamed to a new prefix (say wpk3_) and $table_prefix in wp-config.php was updated to match, those stored names still start with the old one, so WordPress finds no role for anybody. Take a database backup first. Then in phpMyAdmin (from the host's control panel):
    • in the new options table (wpk3_options), rename the row wp_user_roles to wpk3_user_roles;
    • in the new usermeta table (wpk3_usermeta), rename every meta_key that starts with the old prefix: at least wp_capabilities and wp_user_level, plus wp_user-settings and similar.
    The same thing as one query, with your own two prefixes: UPDATE wpk3_usermeta SET meta_key = CONCAT('wpk3_', SUBSTRING(meta_key, 4)) WHERE meta_key LIKE 'wp\_%'; (the 4 is the old prefix's length plus one). If only some tables were renamed, or $table_prefix does not match the tables, fix that first: $table_prefix must equal the prefix the tables actually carry.
  2. Your account lost its administrator role. If the prefix is fine, open wp_usermeta (your prefix), find the rows for your user ID (in wp_users), and check wp_capabilities. For an administrator it reads a:1:{s:13:"administrator";b:1;} and wp_user_level reads 10. Set them, log out and in again. Then ask how it changed: a role-editor plugin, another admin, or someone who should not have had access. If you find administrators you do not know in Users, treat it as a hacked site, not a settings slip.
  3. Only one page refuses you. Admin links such as admin.php?page=some-plugin belong to a plugin. If that plugin is deactivated, deleted or renamed its page, the old link gives this message. Open the dashboard and find the plugin's menu again; reactivate it in Plugins if you still need it. Nothing is broken.
  4. "Not allowed to install plugins" or "edit templates". A line in wp-config.php such as define('DISALLOW_FILE_MODS', true); or define('DISALLOW_FILE_EDIT', true); switches those screens off for everyone, often added by the host or a security checklist. That is a sensible lock; change it only if you mean to, and put it back afterwards.
  5. Multisite networks. Network screens (Network Admin, adding sites, installing plugins) need a super admin. A site administrator gets this message there by design. A super admin adds you in Network Admin, Users.
  6. Test: log out and in, open Dashboard, Posts, Plugins, Settings and Users, edit and save one draft, and check that the front of the site still looks right.

What you see, what it means, what it needs

What you seeUsual causeUsual fix
Every admin page refuses you, right after a host move or a "change the prefix" tipRole stored under the old table prefixRename user_roles in options and the capabilities and user_level keys in usermeta to the new prefix
Every admin page refuses you, prefix unchangedYour account has no administrator roleSet capabilities and user_level back to administrator and 10; find out why it changed
One bookmarked admin page refuses you, dashboard is finePlugin page no longer existsUse the menu; reactivate the plugin if you need it
"Not allowed to install plugins" or "edit templates"DISALLOW_FILE_MODS or DISALLOW_FILE_EDIT in wp-config.phpDeliberate lock: lift it only while you need it
Network screens refuse a site adminMultisite needs a super admin thereA super admin grants it
Unknown administrators in UsersSomeone else got inHacked-site clean-up, new passwords everywhere

What not to do

Fixes 1 and 2 are a few rows in the database and usually take minutes once the cause is clear. If the database is unfamiliar ground, that is what the box below is for. Related: a login page that keeps reloading and "403 Forbidden".