By default, WordPress contributors cannot upload files to the Media Library. This restriction is designed for security, but sometimes you may want to allow contributors to upload images or documents. On ruachost.com, you can enable this capability with a simple PHP function.

 

Why Enable File Uploads for Contributors?

  • Allows contributors to add images or documents to their posts.

  • Improves workflow for content teams.

  • Reduces dependency on administrators or editors for media uploads.

 

Steps to Enable File Uploads

  1. Log in to WordPress with an administrator account.

  2. In the dashboard, go to Appearance → Theme Editor.

  3. Select your active theme and open the functions.php file.

  4. Add the following code snippet at the end of the file:

    // Allow contributors to upload files
    function allow_contributor_uploads() {
        $contributor = get_role('contributor');
        $contributor->add_cap('upload_files');
    }
    add_action('admin_init', 'allow_contributor_uploads');
    
     
  5. Click Update File to save changes.

  6. Log in as a contributor → You will now see the Media option in the dashboard.

✅ Contributors can now upload files directly to the Media Library.

 

Important Notes

  • Always back up your theme before editing functions.php.

  • Use a child theme to preserve changes during updates.

  • Granting upload permissions increases risk, ensure contributors are trusted users.

  • Consider limiting allowed file types for security.

 
War diese Antwort hilfreich? 0 Benutzer fanden dies hilfreich (0 Stimmen)

Powered by WHMCompleteSolution