Ffile2fix
Sign in Get started

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

Sorry, you are not allowed to access this page.

WordPress checked your user's capabilities and found you are not allowed to open this admin page. For an administrator this usually means the role data in the database was lost, often after changing the table prefix or migrating. It can also be a plugin page that was removed or a plugin restricting access.

Also appears as: You do not have sufficient permissions to access this page. (older WordPress) · Sorry, you are not allowed to access this page. (after changing the table prefix) · Sorry, you are not allowed to manage options for this site.

Common causes

  • The table prefix in wp-config.php was changed but the prefix in wp_usermeta and wp_options keys was not
  • The administrator role or wp_capabilities meta was removed or corrupted
  • A deactivated or deleted plugin's admin page is still bookmarked
  • A security or role-editor plugin removed capabilities
  • Multisite: the user is not a network admin for network-level pages

How to fix it

  1. Check whether the page still exists. If the URL is admin.php?page=something from a plugin you removed, the page is gone. Go to the main Dashboard instead.
  2. Fix the prefix after a change. If you changed $table_prefix, update the option_name wp_user_roles in the options table and the meta_key values wp_capabilities and wp_user_level in usermeta to use the new prefix.
  3. Restore the administrator role. Use WP-CLI: wp user set-role yourname administrator. If roles are completely missing, wp role reset --all restores the default roles.
  4. Disable role and security plugins. Rename the folders of role-editor or security plugins in wp-content/plugins to see if access returns. Then review their settings.
  5. Check multisite permissions. On multisite, network admin pages require super admin. Grant it with wp super-admin add yourname.

SQL to update prefixed keys after changing wp_ to wpnew_

UPDATE wpnew_options SET option_name = 'wpnew_user_roles'
  WHERE option_name = 'wp_user_roles';
UPDATE wpnew_usermeta SET meta_key = REPLACE(meta_key, 'wp_', 'wpnew_')
  WHERE meta_key IN ('wp_capabilities', 'wp_user_level', 'wp_user-settings', 'wp_user-settings-time', 'wp_dashboard_quick_press_last_post_id');

How to stop it happening again

  • Back up the database before changing the table prefix
  • Use a tool that rewrites prefixed keys, not only table names
  • Keep at least two administrator accounts
  • Review role-editor plugin changes carefully

Frequently asked questions

Why did this start after changing the table prefix?

WordPress stores roles and capabilities under keys that include the prefix, such as wp_capabilities. Renaming tables without renaming these keys leaves every user without a role.

Can I fix it without WP-CLI?

Yes. Use phpMyAdmin to run the SQL updates for the prefixed keys, or edit the meta_key values by hand.

Is my site hacked?

Usually not. But if admin roles disappeared without any change on your side, check for unknown admin users and modified files.