“You don’t have permission to do that”

One of the most frustrating thing with WordPress is when you are happily moving along, and you come to a comment, or an old post, or an unused category - something like that - and you want to delete it. You click the “Delete: button associated with that link, and nothing happens. You stare at the screen for a bit, maybe hit the button a couple more times to see if maybe it was a weird glitch or something, then you notice it. A little message at the bottom of the screen.

“You don’t have permission to do that.”


Infuriating. You’re logged in as the administrator, and really there’s no higher level. How can *you* NOT have permission to do that? *You* are the one who supplies permissions for anyone else using WordPress, but here it is - some unnamed gremlin with no face, mocking you with your lack of permissions on your own installation where normally, you are king.

Now, there’s a lot of stuff in the forums on this subject. Many times, the simplest fix is to simply reassert your administrative status. Create a new user, and assign it admin status. Log out, and log back in with the new username, and you should have permissions again.

But what if this doesn’t work? In the few times I’ve had this happen to me, the “reassertion” trick has never worked. But I have found a trick that does.

In 2.0.x, you need to go to wp-includes.pluggable-functions.php. Lines 241-247 look like so:

$cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie']));
// AJAX scripts must pass cookie=document.cookie
foreach ( $cookie as $tasty ) {
if ( false !== strpos($tasty, USER_COOKIE) )
$user = urldecode(substr(strstr($tasty, ‘=’), 1)); // Nasty double encoding
if ( false !== strpos($tasty, PASS_COOKIE) )
$pass = urldecode(substr(strstr($tasty, ‘=’), 1));
}

Simply comment out that section, and replace it with this:


$user = $_COOKIE[USER_COOKIE];
$pass = $_COOKIE[PASS_COOKIE];

Problem solved.

(In the case of 2.1.x, I don’t know what the line numbers are, but it’s the wp-includes/pluggable.php file, and it’s the same code. I know it’s in the same general area - give or take a few line numbers.)


Comments

toocool says...
1

I have problem whenever i comment on any wordpress site it says Your comment is awaiting moderation can u help to get rid of this

Jacques says...
2

What I do, once I got that error (which was randomly - other than not making sense at all, as I’m always the uber-admin of MY WP-installs and those of clients), is to check the ‘remember me’ option on logging in - it might write\edit a cookie which stores your admin-role - not sure, never checked it, but seems to make a difference.

Also, logging in in WP using FireFox seems to give less hassles than IE7.0…

Shelly says...
3

>>is to check the ‘remember me’ option on logging in - it might write\edit a cookie which stores your admin-role - not sure, never checked it, but seems to make a difference.<<

Oo..I’ll have to give that a try if it ever happens again. That’s *definitely* much simpler - and you don’t have to edit core files (which is even better!)

>>Also, logging in in WP using FireFox seems to give less hassles than IE7.0…<<

This is true as well, but I don’t think the browser matters. I use Firefox as my main browser, and it still happens on occasion. Which is funny - I’ve found that if it does this in Firefox, and you switch to using IE, it’ll work fine in IE…and vice versa.

Trackbacks & Pingbacks

Leave a Reply