search ]

Allow Contributors to Upload Images in WordPress

By default, WordPress does not allow users with the Contributor role to upload images to the media library. Of course you could give that user higher-level permissions, but that would allow them to perform additional actions on the site that you may not want them to be able to perform.

The following code lets Contributor users upload images to posts they wrote without any additional permissions:


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

if (current_user_can('contributor') && !current_user_can('upload_files'))
    add_action('admin_init', 'sv_allow_contributor_uploads');

For more on file uploads in WordPress, see Enable Additional File Type Uploads.

Join the Discussion
0 Comments  ]

Leave a Comment

To add code, use the buttons below. For instance, click the PHP button to insert PHP code within the shortcode. If you notice any typos, please let us know!

Savvy WordPress Development official logo