Adding prefix to WordPress database tables breaks admin capabilities?

I have attempted a few different ways (manually, using Brozzme’s DB Prefix Tools & Addons plugin) to add a prefix to an older WP database (right now table names look like posts instead of wp_posts or stx_posts, etc.).

Strangely, no matter what way I do it, something breaks after adding the prefix. Everything is updated in wp-config.php fine to reflect the prefixes existence but when I attempt to navigate the admin side of things I get an error page instead:

“Sorry, you are not allowed to access this page.”

This has me completely confused as adding a prefix to the tables shouldn’t cause anything to change with user’s permissions! Has anyone seen this problem before?

P.S. Not sure if this is relevant but the current host is Cloudways. I’m not sure how this would be involved but I’ve seen some weird caching issues with Cloudways. For example, I’ve deleted a file using SSH from the server, everything works, and then a little later the file is back.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

In the $wpdb->prefix_usermeta table, there is a meta key called $wpdb->prefix_capabilities.

When users are created, the $prefix is hard-coded. You have to also edit the $prefix to the new one there.

So in your example

wp_capabilties becomes stx_capabilities. You must update it for all users.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x