Skip to content

Instantly share code, notes, and snippets.

@terrytsang
Last active September 11, 2022 09:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terrytsang/06d1e9625172bf4ce4a75501273fc0de to your computer and use it in GitHub Desktop.
Save terrytsang/06d1e9625172bf4ce4a75501273fc0de to your computer and use it in GitHub Desktop.
Enable contributor to upload images
<?php
//add this code into theme functions.php file
if ( current_user_can('contributor') && !current_user_can('upload_files') ) {
add_action('admin_init', 'allow_contributor_upload_image');
function allow_contributor_upload_image() {
$contributor = get_role('contributor');
$contributor->add_cap('upload_files');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment