How To Allow Contributors To Upload Images In WordPress

wpA good post is incomplete without a good image and I don’t think the WordPress developers knew about it while they were creating WordPress. 😀

Wondering why I said it?

Read on.

WordPress has different roles for different users; every role has got different privileges according to the person using the account.

These roles range from subscribers to authors, contributors, editors and administrators.

Among these the administrator has access to each and every part of the wordpress dashboard while there are limitations for other roles.

In this post, today we are going to discuss one such limitation which you won’t wish to have.

WordPress does not allow contributors to upload images in posts.

I find it quite awkward, a contributor can add an image to a post if he knows a bit of html, he can add an image using the <img src> tag in HTML but he can’t directly upload it the normal way.

If you are the only one who posts on the blog then there is no need to go through this tutorial as you don’t have any contributors so no problems.

If you accept guest posts on your blog then dare you miss this, I will kill you 😀

Just Kidding!!

I also accept guest posts on Inside Tech Tricks and the guest blogger has to signup as a subscriber first and then I update his role from subscriber to contributor. One such guest blogger emailed me regarding this problem he was facing while adding image to his post.

So without wasting a moment I went on to search the solution to this problem and thanks to Google, I found a code to solve this problem.

So now let us go through how to do this

To allow contributors to upload images to their posts here are the steps you need to follow

Login to your dashboard

Go to appearance

Click on editor

Now search for the file “functions.php” on the list in the right hand side and click on it.

Functions.php is the file where we are going to add our code

Now add the following code at the end or in the starting of the functions.php file

<code>if</code> <code>( current_user_can(</code><code>'contributor'</code><code>) &amp;&amp; !current_user_can(</code><code>'upload_files'</code><code>) )</code>
    add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
    $contributor = get_role('contributor');

Thanks to Cats Who Code for this Code, Cheers Guys!

That’s all we need to do, no hectic and complicated coding just paste the code and POOF! Its done.

Over To You

Though there a few plugins which allow you to play with roles and permissions with a few clicks but I actually don’t prefer using Plugins for things which can be done easily by adding a piece of code.

Reason of not a using a plugin is, What if the Plugin breaks with a new Update in WordPress and some worst things happen?

In spite of these type of small issues we face with WP I still thank Matt Mullenweg for making it flexible enough so that we can customize it according to our needs.

Do let me know your views on this post.

And If you have some friends using WordPress then share this post with them too using the share buttons below.


Leave an awesome and valuable reply