How to Let Contributors Upload Images & Edit Published Posts in WordPress

One of the things I always found odd with WordPress is that Contributors cannot upload media, nor can they edit their own posts once published. I understand it’s the lowest permission level for creating posts, however, it has the perfect capabilities for guest authors otherwise. The only thing they can do is work with their own posts, which is all you want to give a guest author typically.

So, I’ll show you how to easily give contributors the ability to upload media to their posts, and to edit their own posts once they’ve been published.

The Code

There are two ways you can give a contributor these capabilities, and the first is by putting some code into your theme’s functions.php file. I would only recommend doing this if you have a child theme you’ve created. If it’s a theme you’ve downloaded then this code will be lost the next time you run a theme update.

The code you want to put into the theme’s functions.php file is:

add_action('admin_init','contributor_set_cap');

function contributor_set_cap() {		
	$contributor = get_role('contributor');
	$contributor->add_cap('upload_files');
	$contributor->add_cap('edit_published_posts');
}

That’s it.

The code assigns the rights to upload media and edit published posts to contributors. This is a very blunt method for doing it, which has made it the most reliable of those I’ve tried.

The only problem with doing the above method is that there’s no way to remove the permissions should you require. To do that I would recommend creating this as a plugin.

Create Your Own Plugin

The other alternative is to create your own plugin for this. This is my preferred method because it will work regardless of your theme. Meaning, you don’t have to remember to paste the code into a new theme you’ve setup.

If you’ve never created a plugin before, it’s really simple. The first thing you’ll want to do is to create a folder to put your PHP file into. For myself, I created a folder called contributor-capabilities.

Inside that folder you will want to create a PHP file. The file I created I called cc.php.

Inside that PHP file, add the following code:

<?php

/*
	Plugin Name: Contributor Media Upload & Post Edit
	Plugin URI: http://blogplayground.com/
	Description: Lets a contributor upload media and edit their published posts.
	Author: Thor
	Version: 1.0.0
	Author URI: http://blogplayground.com/
*/

add_action('admin_init','contributor_set_cap');
register_deactivation_hook( __FILE__,'contributor_deactivate');

function contributor_set_cap() {		
	$contributor = get_role('contributor');
	$contributor->add_cap('upload_files');
	$contributor->add_cap('edit_published_posts');
}
function contributor_deactivate() {
	$contributor = get_role('contributor');
	$contributor->remove_cap('upload_files');
	$contributor->remove_cap('edit_published_posts');
}

?>

It’s the same code as the previous example, with the addition of having the required part that designates it as a plugin to WordPress, and the removal of permissions on deactivation. So, if you deactivate this plugin then the contributor will not be able to upload media or edit their published posts.

Notice the top part of the file, in the comments, with Plugin Name, Plugin URI, etc. That gives WordPress information about the plugin, so feel free to change that to whatever you want.

Upload

Once you’ve got that completed, you need to upload the plugin. There are two ways to do that.

  1. FTP into your web host and upload the folder with the file to wp-content/plugins/
  2. Zip the folder with file, then go to Plugins->Add New->Upload Plugin.

If you do the first option, you’ll need to go to Plugins to activate it. If you do the second option, you will get the option to activate it once uploaded.

Please Rate this Article

Please take a second to rate this. It helps us deliver to you the stuff you enjoy.

How to Let Contributors Upload Images & Edit Published Posts in WordPress
5 (100%) 4 votes

Author: Thor

I started blogging in 2009 for my gaming blog Creative Twilight. I've been blogging ever since.

I later created Command Center, a tool for 40K. I've also set up, maintain, and run my wife's site ecoLifestyle for her business.

I'm also a PHP programmer for a local web hosting company where I develop WordPress plugins.

Leave a Reply!

Note: You can comment as a guest by clicking the field indicated Name and checking off “