X

How to Allow Contributors to Add Images in WordPress

Snippets by IsItWP

Do you want to allow contributors to upload images without providing them with the ability to delete other images in WordPress? Follow our instructions to allow image uploads for contributors.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

<?php
//allow contributor to add photos
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');
    }
}
?>

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: Best WordPress Page Builders (Compared).

[code]add_cap('upload_files'); } } ?>[/code]

Comments   Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!