WordPress: Allow Contributors to Upload Images

WordPress is a very flexible platform for site owners.  Unfortunately, by default, WordPress limits many of the things you can do right off the bat.  One thing I have encountered lately is the need to have contributors upload images to insert into posts as this is not allowed from the start with WordPress.  You may be asking, why is this a big deal? Just make them Authors.  Well, the answer is with the roles within WordPress.

There are slight differences between the roles in WordPress:

  • Super Admin – Someone with access to the blog network administration features controlling the entire network (See Create a Network).
  • Administrator – Somebody who has access to all the administration features
  • Editor – Somebody who can publish and manage posts and pages as well as manage other users’ posts, etc.
  • Author – Somebody who can publish and manage their own posts
  • Contributor – Somebody who can write and manage their posts but not publish them
  • Subscriber – Somebody who can only manage their profile

Authors have the ability to upload files, but also have the ability to publish at will.  I personally want to maintain control over what gets published on sites and this can be done by assigning someone the role of contributor, but the role of the contributor is not allowed the privilege of uploading images and attaching them to their posts.

To get around this? Open up your functions.php file for editing and insert the following:

// --------------------------------------------------------------------------
// Start contributors upload images
// --------------------------------------------------------------------------
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');
}
// --------------------------------------------------------------------------
// End contributors upload images
// --------------------------------------------------------------------------

Note: These functions are not of my own creation, simply things I have found along the way.  If you are the author of this function, please let me know so I can properly credit you with your work!

About Joe D

I have always had a passion for everything computing. In early 2000, I decided to take my passion to the web. Thus, C.O.D. was born. Through the years we have made many great friends at C.O.D. and hope to continue our journey for years to come.

Check Also

Manage Multiple WordPress Sites with InfiniteWP

Running your website, or websites, on WordPress is an easy choice as the flexibility the …

2 comments

  1. 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/

    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,

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.