Little adventures building sites with Wordpress…

How To Allow Contributor User Role Upload Images

with 6 comments

One of the many questions people asked me is how do you allow a contributor in WordPress to upload images and files.

The Contributor User Role allows you to write a post and submit it for pending review by the Administrator to approve and publish. That’s by default and the big disadvantage here is that you don’t have the ability to upload images or files in the post.

There is a way. Add the following code to the file functions.php:

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');

That’s it. Now your Contributors should be able to upload images or files in the post and submit it for pending review.

Hope this helps. =D


Written by Yahya Ayob

November 2, 2010 at 7:18 am

Posted in coding, WordPress

6 Responses

Subscribe to comments with RSS.

  1. Very good, thank you very much


    February 12, 2011 at 4:09 pm

  2. I added this code to the functions.php file in my template and it did work. But, I decided I didn’t want to have the image upload ability anymore for contributors. I deleted the code, but the upload icons are still there. Now, how do to remove the ability to upload images for contributors? I need those upload icons removed. Please help!


    March 30, 2011 at 8:50 am

    • That’s a good question. I have not come up with the solution but perhaps soulsizzle will be looking into this problem as the code originated from him.

      I was searching for clues and answers and I found this link – http://www.nouveller.com/quick-tips/quick-tip-9-change-the-default-capabilities-of-wordpress-users-with-ease/ by Benjamin Reid. I’ve tried his method hoping to remove the icons but the icons are still there.

      If anyone else can come up with a solution, please contribute to help.

      Yahya Ayob

      March 30, 2011 at 11:38 pm

      • Yahya,Thanks for the response. 🙂 After hours of trying to write code to remove this I was unsuccessful. The best solution I came up with was just to go into the database and remove the ‘file upload’ for contributors. Do a SQL command: SELECT * FROM wp_options WHERE option_name=”wp_user_roles”

        Find: s:11:”contributor”;a:2:{s:4:”name”;s:11:”Contributor”;s:12:”capabilities”;a:6:{s:10:”edit_posts”;b:1;s:4:”read”;b:1;s:7:”level_1″;b:1;s:7:”level_0″;b:1;s:12:”delete_posts”;b:1;s:12:”upload_files”;b:1;}}

        Replace with:

        This should remove this. Worked for me.

        Phil Ginsburg

        April 11, 2011 at 7:11 am

      • Dear Yahya Ayob,

        There is solution for above mentioned problem.

        Download plugin: capsman


        Select “Upload Files” and get the positive results.


        Quote Searching

        December 25, 2012 at 1:55 am

    • You know how you use $contributor->add_cap(‘upload_files’) to add the capability? That actually updates the database to provide the capability to the role.

      To remove it, just do the same thing, but use $contributor->remove_cap(‘upload_files’). That’ll get that stuff back out of the database, and then you can remove the code all together or disable your plugin.

      Andrew Angell

      April 26, 2012 at 3:58 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: