Upload & Insert images as a WordPress contributor

For my Marbella news site I recently hired an excellent free-lance writer on Elance to assist me in composing quality articles. As the site is also powered by WordPress I added him as a contributor to start of with. He explained he had some trouble adding images per the guide I sent him. The “Upload/Insert” image button was simply not there.

So to summarise, the WordPress contributor role apparently lacks this permission. There are a few plugins around that can let you tweak those permissions with more granularity, but I just needed that single change.

A bit of searching revealed exactly what I needed. One minor change in the theme’s functions file was sufficient to upload & insert images as a WordPress contributor:

if ( current_user_can('contributor') && !current_user_can('upload_files') )
	add_action('admin_init', 'allow_contributor_uploads');
 
function allow_contributor_uploads() {
	$contributor = get_role('contributor');
	$contributor->add_cap('upload_files');
}

This also keeps the core clean for changes which makes upgrading WordPress later on less time consuming.

Comments

8 responses to “Upload & Insert images as a WordPress contributor”

  1. ben avatar
    ben

    works even today! i just pasted at the bottom of my functions.php, worked like a charm.

  2. Fairooz @ TechnoTweaks avatar

    Thats a really working one.. I tried it on my blog and it worked… Thank you very much!!

  3. Bhavesh Sondagar avatar
    Bhavesh Sondagar

    I am using members wordpress plugin to allowing roles to users, however this tutorial is helpful for those who hates plugin but loves coding.

    thanks for this great post.

  4. Martin Oxby avatar
    Martin Oxby

    Even though this is really old now, this has done exactly what I need even on a new WP version, thanks for sharing:)

  5. admin avatar
    admin

    WP 3.0.4, BP 1.2.7

    Just need CONTRIBUTORS to upload and SET FEATURED IMAGE, after plug the code indicated by you in this article, at the begining of the functions.php file under http://domain.com//wp-content/plugins/buddypress/bp-themes/bp-default/functions.php

    However, when I try or click the SET FEATURED IMAGE on a new post, I’m still receiving “You do not have permission to upload files.” message.

    How to fix this ?

    Regards,

  6. Jay avatar
    Jay

    Oh my, I love the community that WP has, I’ve found answers to all my questions in the last few days… Thanks for showing me how to do this. I’ve been out of the WP scene for a few months and seemed to have lost my SP skills 🙂 Thanks

  7. Pothi avatar
    Pothi

    Thanks for the tip. It works flawlessly. Thanks so much!!!

  8. Phil Harris avatar
    Phil Harris

    Thanks!! This is exactly what I was looking for. A way to make the modification without changing the core files.

Leave a Reply

Your email address will not be published. Required fields are marked *

Why ask?