“Sorry, you are not allowed to access this page.”
You're logged in, but the user lacks permissions. It can happen after a migration, a database error or a break-in.
- You need
- WP admin
- Updated
WordPress shows this message when your user lacks the capability required for the page you're opening. If it only happens on one page, the link may lead to a plugin that is no longer active.
If it happens across all of wp-admin, your user has lost the administrator role. That can happen, for example, after a migration where the database table prefix was changed, after a database error or after a break-in. A role editor plugin, such as User Role Editor, can also have removed capabilities from the administrator role.
Check whether it's just one page
- Go straight to
/wp-admin/on your site. - If the dashboard loads, you still have access. Check under Plugins whether the page you tried to open belongs to a plugin that has been deactivated or deleted.
- If you get the message here too, your user has lost the administrator role. Move on to the next step.
Ask another administrator to check the role
If the site has another administrator, they can fix it in wp-admin.
- Go to Users → All Users and click your username.
- Set Role to Administrator.
- Click "Update User".
If you have SSH and WP-CLI, this command does the same:
wp user set-role username administrator
Check the table prefix after a migration
Your role is stored in the database under keys that start with the table prefix. If the prefix was changed in wp-config.php during the move but not inside the database, WordPress can no longer find the roles.
- Open
wp-config.phpwith FTP or the file manager and find$table_prefix, for example'wp_'. - Open phpMyAdmin in your hosting panel and check that the tables start with the same prefix.
- Find your ID in the
IDcolumn of thewp_userstable. - Open the
wp_usermetatable and look at the rows with youruser_id. Two of them should havewp_capabilitiesandwp_user_levelin themeta_keyfield, with your prefix instead ofwp_. - In the
wp_optionstable, the row holding the roles should be namedwp_user_roles, also with your prefix. - If any of these keys still has an old prefix, change it to match
wp-config.php.
Give the user the administrator role in the database
If the rows are missing or empty, add the values yourself in wp_usermeta for your user_id. wp_capabilities should have this value:
a:1:{s:13:"administrator";b:1;}
wp_user_level should have the value 10. Log out and back in afterwards.
If the wp_user_roles row in wp_options is empty or broken, every user loses their permissions at once. The safest fix in that case is to restore that row from a backup. With WP-CLI, wp role reset --all puts the default roles back. Roles added by plugins, such as WooCommerce's, aren't restored.
If nobody has moved the site
If the role disappeared without the site being moved or changed, someone may have taken over the site and removed you as administrator. Change the passwords for the hosting panel, FTP and the database before you do anything else. Put the new database password in DB_PASSWORD in wp-config.php right away, or the site loses its connection to the database. Once you have the administrator role back, look for unknown administrators under Users and change the WordPress passwords.
When you're stuck
Without another administrator, WP-CLI or phpMyAdmin access, you can't give yourself the role back. Whoever holds the hosting account has to give you access. If the roles are missing for every user and there is no backup, a developer has to rebuild them in the database. That takes experience with WordPress databases.