I'm integrating an image upload action, on the options page for my plugin.

It works, but the thickbox dialog sits with a message "crunching" and never completes. Checking the console in Firebug shows that the error message "you are not allowed to edit this item" is being returned.

I can get past the error by add_cap("edit_posts") to the user's role -- but I really cannot do that since it opens up too many other privileges in Admin.

So, how does one use media-upload to simply upload an image and get back the resulting URL -- without media-upload thinking that the user needs edit_posts capability? The call to the uploader from jQuery click event looks like this:

tb_show('Upload a Image', 'media-upload.php?referer=media_page&type=image&TB_iframe=true&post_id=0', false);

1 Answer 1


The solution to this is pretty ugly. First, I am going to have to create all posts in this system starting at a high ID number (say, 10000). I'll have to do this via wp_insert_post with the "import_id" suggestion. That will move all the content I don't want the user to be able to touch, to a safe range.

Then, using the method described here: http://mawaha.com/allow-user-to-edit-specific-post-using-map_meta_cap/

map the meta capability for "edit_post", when post number is less than 10000.

It works, but man I wish WP allowed a capability filter to be added to the media handler :-(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.