It may be WordPress security measure (is it? Really?). The users have different roles. Each role gets a certain set of privileges. But not having option to upload images for contributors is really hindering, isn’t it?


                                            where is the add images option?
  
                                                          



Image courtesy of David Castillo Dominici / FreeDigitalPhotos.net


If you are the only person to compose and publish posts, there’s no problem. You’ll never need to allow contributors to upload image. But what if it is a multi-authored blog? What if you welcome lots of guest posts? Is it not nuisance to receive preferred images in email, upload them and publish in the post written by your contributors?

I write posts for some great blogs – Ileane’s BasicBlogTips, Stephane’s Dukeo, Enstine’s emFastIncome, Erik’s NoPassiveIncome.com & Bashir’s Ajnabii. I will be writing soon for Devesh’s WPKube. And the problem is not less obstructing to me as well. In some cases, I compromised with the image the publisher set for my post and in some other cases I sent the images separately and requested them to fix it for me. I wish if they allow contributors to upload image.

Simply wonder why we not allowed to upload images.

When I was fixing images for Ambika’s post, I planned to look for ways so that the Bivori contributors can upload and insert images in their post. I went to Mr. know all – Google, and had a brief conversation.

Though the problem looks really big, the solution is startlingly simple! You can allow contributors to upload images within a couple of minutes if you’re not scared to touch the code of your theme

Okay, don’t be afraid, it is not that risky and we’ll not tough any core files!

How to  upload images?

Okay, to make this change in WordPress, you need a code snippet and know where to paste the snippet. Every theme has a functions.php file to add some codes to extend functionality of your blog. Find that file.

I got to it through Appearance » Editor » Theme Functions (functions.php)

Did you get that file? Does it already contain some codes? Fine, no problem. You’ll add the new code at the end of this file.

Now let’s fetch the required code.


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’);
}


Copy above code and paste it at the end in your functions.php file. Great! You did it!

Now your guest authors will be happy because they know what image goes best at where in their post. They are allowed to upload images in their posts!

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Related Posts Plugin for WordPress, Blogger...

- Copyright © 2013 All Ping