Open
Front-end forms that include a WYSIWYG editor (including for the post content) can include an Add Media button (determined by the form settings).
That opens up the WordPress Media Library, which may display all uploaded media, or—according to Access settings for the form—may only show the current user’s own uploads.
That setting works for media fields, but not for the Add Media button on a WYSIWYG editor, when all media are always shown.
There currently is no workaround.
2 temporary workaround.
1_Using this plugin seems to fix the issue: https://wordpress.org/plugins/frontier-restrict-media/
2_this custom code work only for grid view. Switching to list view will show all media files in media library.
add_filter( 'ajax_query_attachments_args', 'role_azienda' );
function role_azienda( $query ) {
$user_id = get_current_user_id();
if ( $user_id && current_user_can('azienda') ) {
$query['author'] = $user_id;
}
return $query;
}