For a while I’ve been struggling to update my blog to a newer WordPress version. I had some issues because now I’m hosting it on an AWS instance and had to do some tinkering to make it work. But in the end I did it. I’ve upgraded my blog to the latest WordPress version. However this had an unexpected result. I couldn’t write any posts because it was keep throwing me the following error: “You are not allowed to edit this post.“. Pretty strange considering that i was logged in with an admin user.
So I’ve been digging around to find the cause of this problem and i had not much luck for a while. All I could figure out that it was some kind of a database error involved. But after some debugging i managed to narrow it down to the wp_posts table and the fact that the ID column didn’t have an auto increment flag set. After I’ve added auto increment to this column my problem went away. Only to discover that i had some other problems like images cannot be uploaded and attached to posts. Guess what ? The problem was in the database as well. And it was also the lack of auto increment on the wp_postmeta table. So I went and added auto increment to that one and also to a few other tables where i considered that an auto increment is missing and it could be needed. So far so good, it’s working.
So it is as simple as that. If you encounter this error you might be able to fix it just by adding auto increment to the ID column in the wp_posts table and some other tables that doesn’t have this option set.