> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Enabling file upload function for contributors using PHP function in WordPress

> Discover how to enable file uploads for contributors via the WordPress media menu using PHP code.

[WordPress](https://hosting.com/hosting/platforms/wordpress-hosting/managed-wordpress-hosting/), by default, does not allow contributors files to the site. [WordPress](https://hosting.com/hosting/platforms/wordpress-hosting/managed-wordpress-hosting/) contributors do not have the media tab on the dashboard to add any media files to the library. This article shows you how to add a media tab and allow contributors on your [WordPress](https://hosting.com/hosting/platforms/wordpress-hosting/managed-wordpress-hosting/) site to upload files using a simple PHP code snippet.

## Enable media tab for contributors in WordPress

<Warning>
  **Important**

  Always perform a backup before you make any changes to the theme files. If you break any codes, it will be easier to revert your site to its last good known state. Alternatively, you could also create a child theme. Read this link on how to create a child theme: [https://www.hosting.com/blog/wordpress-child-theme/](https://www.hosting.com/blog/wordpress-child-theme/)
</Warning>

Follow the steps below to edit your Theme setting file to enable media tab for WordPress contributors:

1. Log in to your WordPress site with an administrator account.

2. On the **Dashboard** in the left sidebar, click Appearance, and then click **Theme Editor**:\
   ![](https://static.hosting.com/kb/kb-wp-enablefileupload-2.png)

3. On the Theme Editor, select the Theme you want to edit from the dropdown:

4. The files for this selected theme are listed on the right column under **Theme Files**. Click on the file named "**functions.php**":\
   ![](https://static.hosting.com/kb/kb-wp-enablefileupload-1.png)

5. Insert the following code to the end of **functions.php** file and click on **Update** to save the changes:

```javascript theme={null}
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'); 
} 
```

5. Click on the **Update** file button to save your changes to the **functions.php** file.

6. Before: Media option is not available for contributor![](https://static.hosting.com/kb/kb-wp-enablefileupload-4.png)

7. After inserting the script: Contributor has the Media option to upload files:\
   ![](https://static.hosting.com/kb/kb-wp-enablefileupload-3.png)

## Related articles

* [Backing up WordPress](/docs/backing-up-your-wordpress-site)

* [Carousel Slider for WordPress](/docs/carousel-slider-for-wordpress)

* [Changing the WordPress theme manually](/docs/changing-the-wordpress-theme-manually)

* [Clearing the cache in WordPress](/docs/clearing-the-cache-in-wordpress)
