WordPress – Allow Contributors to Add / Upload Media

In WordPress by default the Add Media functionality (called Capability in wordpress terms) is disabled for users with Contributor role. If you are hosting multiuser wordpress site where users with contributor roles logs in and update their post, they would not be able to add images / medias. That’s quite annoying. The user who is editing a post must be able to add supported media for their post.

Check below screenshot. The current user has “Contributor” role. Hence she is not able to view Add media button.

Now to overcome this there is a simple trick. By using WordPress’s add_cap method we can add different capabilities to user. So we can add upload_files capability to a Contributor using this method.

Add following code in functions.php file of your current wordpress theme.

// Allow Contributors to Add Media 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'); }
Code language: PHP (php)

Now logout and login again using a user with contributor role. Ta’da.. Add media button is visible now.

Use this simple trick to make Add media button visible for contributors on your wordpress site. I think this simple trick will help those who have contributors on their site.

View Comments

Share
Published by
Viral Patel
Tags: php code snippet wordpress wordpress tips

Recent Posts

  • Java

Java URL Encoder/Decoder Example

Java URL Encoder/Decoder Example - In this tutorial we will see how to URL encode/decode…

5 years ago
  • General

How to Show Multiple Examples in OpenAPI Spec

Show Multiple Examples in OpenAPI - OpenAPI (aka Swagger) Specifications has become a defecto standard…

5 years ago
  • General

How to Run Local WordPress using Docker

Local WordPress using Docker - Running a local WordPress development environment is crucial for testing…

5 years ago
  • Java

Create and Validate JWT Token in Java using JJWT

1. JWT Token Overview JSON Web Token (JWT) is an open standard defines a compact…

5 years ago
  • Spring Boot

Spring Boot GraphQL Subscription Realtime API

GraphQL Subscription provides a great way of building real-time API. In this tutorial we will…

5 years ago
  • Spring Boot

Spring Boot DynamoDB Integration Test using Testcontainers

1. Overview Spring Boot Webflux DynamoDB Integration tests - In this tutorial we will see…

5 years ago