Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › Restrict access to content by Author in Media Library › Reply To: Restrict access to content by Author in Media Library
11/09/2017 at 05:31
#4166
Vladimir
Keymaster
Hi @rheinstars-loeln,
try to add this code to your active theme functions.php file:
add_filter('ure_restrict_edit_post_type', 'exclude_attachments_from_edit_restrictions');
function exclude_attachments_from_edit_restrictions($post_type) {
$restrict_it = true;
if (current_user_can('author')) {
if ($post_type=='attachment') {
$restrict_it = false;
}
}
return $restrict_it;
}
Replace ‘author’ role inside with any other role, for which you need allow access to all attachments in spite of edit restrictions set for posts or pages.