I actually create an extranet space on my website, with pages where you must to be logged-in to see the content. My problem is about media uploads. I want to make them private for a specific custom post type, and upload them in a sub directory (uploads/private). I use the upload_dir filter (add_filter('upload_dir', 'extranet_upload_directory');) with success for thumbnail for exemple, but when I upload an image in the content with a gutenberg block, this one is upload in the initial foldier (uploads), not in uploads/private.
Does anyone have an idea where to look at ?
My code below :
add_filter('upload_dir', 'extranet_upload_directory');
function extranet_upload_directory( $param ){
$id = $_REQUEST['post_id'];
if ( ( get_post_type( $id ) == 'test-extranet' ) ) {
$param['subdir'] = '/private' . $param['subdir'];
$param['path'] = $param['basedir'] . $param['subdir'];
$param['url'] = $param['baseurl'] . $param['subdir'];
}
return $param;
}