There are many WordPress sites need to open backstage to accept user submissions, in general we will be the default role of the new user is set to: contributor .
In WordPress, the contributor user in the background to add new articles, can only publish text content, can not add media, that is, can not upload pictures, videos, compressed packages and other files. But for many sites, pictures and other media to enrich the content of the article, increased readability played an essential role, so contributors can not upload pictures is really inconvenient. This article will explain to you in WordPress How to give contributors the ability to upload files.
The method is simple, use a text editor to open the functions.php in the current theme directory, and add the following code:
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 ');}
Once the above code has been executed once, the contributor's permission settings will be stored in the database, and even if you remove the above code, the contributor will still have permission to upload the file. If you want to deprive contributors of the ability to upload files, you can use the following code to replace the above code:
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->remove_cap (' upload_files ');}
Then use the Contributor account login to the wordpress background Article publishing page to see if there is no media add button. If the button is gone, you can remove the above code.
WordPress allows contributors to upload images as well