WordPress allows contributors to upload images as well

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.