WordPress media library upload restriction
WordPress media library upload restriction, just copy the code below to your functions.php
Or install this plugin to do the task WDES User Upload Restriction – https://wordpress.org/plugins/wdes-user-upload-restriction/.
add_action('pre_get_posts','wdes_users_own_attachments'); function wdes_users_own_attachments( $wp_query_obj ) { global $current_user, $pagenow; if( !is_a( $current_user, 'WP_User') ){ return; } if( !in_array( $pagenow, array( 'upload.php', 'admin-ajax.php' ) ) ){ return; } if( !current_user_can('delete_pages') ){ $wp_query_obj->set('author', $current_user->ID ); } return; }