Skip to content

Instantly share code, notes, and snippets.

@versluis
Created July 25, 2019 13:30
Show Gist options
  • Save versluis/76ebdf62fc24605e8ac15f519168ead0 to your computer and use it in GitHub Desktop.
Save versluis/76ebdf62fc24605e8ac15f519168ead0 to your computer and use it in GitHub Desktop.
adds file upload capabilities to the Contributor Role in WordPress
// add file uploads to Contributor role
function add_uploads_to_contribs () {
global $pagenow;
// grab contribtor role
$role = get_role ('contributor');
// if this theme is activated, add the upload capability
if ('themes.php' == $pagenow && isset ($_GET['activated'])) {
$role -> add_cap ('upload_files');
} else {
// remove when deactivated
$role -> remove_cap ('upload_files');
}
}
add_action ('load-themes.php', 'add_uploads_to_contribs');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment