It is pretty cool how WordPress manages user and restrict access via defined roles but one of the critical part of the website are the images. Once you give access to your editors they will have capability to view and delete images even if they are not uploaded by them which will ruin the pages and posts that are using it. On some points you don’t want the site users, freelancers or even general public to access the images. Well then you came to the right page This tutorial also covered the ability to hide the posts that are created by other users so that the current users cannot make any changes. First you need to be able to access the editor by navigating to Appearance > Editor and find the theme’s functions.php That’s great you have the required access Add the code below which will hide the posts and images uploaded by other users except for administrator on /wp-admin/edit.php and /wp-admin/upload.php <?php function hide_posts_media_by_other($query) { global $pagenow; if( ( 'edit.php' != $pagenow && 'upload.php' != $pagenow ) || !$query->is_admin ){ return $query; } if( !current_user_can( 'manage_options' ) ) { global $user_ID; $query->set('author',
Share This