wordpress为用户显示媒体文件

I would like to present the user only his media files but only if he is in a custom group (Teachers). If he is Author or above he can see all media files.

e.g. I have a user Teacher 1 and he is in group Author and Teachers. User Accountant is in group Author.

Teacher can see only his files, Accountant can see all files.

I tried the following funcition

 function wpb_show_current_user_attachments( $query ) {
$user_id = get_current_user_id();
if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts') ) {
/*        $query['author'] = $user_id;*/
    $query['Teacher'] = $user_id;
}
return $query;
} 

add_filter( 'ajax_query_attachments_args', 'wpb_show_current_user_attachments' );

Thank you